<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: front_end_shifu_2022</title>
    <description>The latest articles on DEV Community by front_end_shifu_2022 (@front_end_shifu_2022).</description>
    <link>https://dev.to/front_end_shifu_2022</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F600046%2Fd4ff5a00-6016-4281-94c9-25f3f365a4fa.jpg</url>
      <title>DEV Community: front_end_shifu_2022</title>
      <link>https://dev.to/front_end_shifu_2022</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/front_end_shifu_2022"/>
    <language>en</language>
    <item>
      <title> When and where should we use normal function as opposed to arrow function ?</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Fri, 04 Jun 2021 07:17:02 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/when-and-where-should-we-use-normal-function-as-opposed-to-arrow-function-3hfd</link>
      <guid>https://dev.to/front_end_shifu_2022/when-and-where-should-we-use-normal-function-as-opposed-to-arrow-function-3hfd</guid>
      <description>&lt;p&gt;##When and where should we use normal function as opposed to arrow function ?##&lt;br&gt;
&lt;em&gt;"this" binding&lt;/em&gt;&lt;br&gt;
Unlike regular functions, arrow functions don’t have their own this or arguments binding. Instead, those identifiers are resolved in the lexical scope like any other variable&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“arguments” binding&lt;/em&gt;&lt;br&gt;
Arguments objects are not available in arrow functions, but are available in regular functions.&lt;br&gt;
Regular function:&lt;br&gt;
let myFunc = { &lt;br&gt;
 showArgs(){ &lt;br&gt;
   console.log(arguments); &lt;br&gt;
 } &lt;br&gt;
}; &lt;br&gt;
myFunc.showArgs(1, 2, 3, 4);&lt;br&gt;
Arrow function:&lt;br&gt;
let myFunc = { &lt;br&gt;
 showArgs : ()=&amp;gt; {&lt;br&gt;
      console.log(arguments); &lt;br&gt;
   }&lt;br&gt;
}; &lt;br&gt;
myFunc.showArgs(1, 2, 3, 4);// error&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Arrow functions cannot be called with “new"&lt;/em&gt;&lt;br&gt;
If a function is constructible, it can be called with new. If a function is callable, it can be called without new.&lt;br&gt;
Regular functions created through function declarations / expressions are both constructible and callable.&lt;br&gt;
Arrow functions  are only callable i.e arrow functions can never be used as constructor functions. Hence, they can never be invoked with the new keyword.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When Not to Use Arrow Function&lt;/em&gt;&lt;br&gt;
Here are few cases where you shouldn't look at arrow function:&lt;br&gt;
1:)Object methods&lt;br&gt;
var david = {&lt;br&gt;
  burger: 3,&lt;br&gt;
  eatBurger: () =&amp;gt; {&lt;br&gt;
    this.burger--;&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
When you call david.eatBurger, the number of burgers does not decrease. It is because this is not bound to anything, and will inherit the value of this from its parent scope.&lt;/p&gt;

&lt;p&gt;2:) When it makes your code less readable&lt;br&gt;
. With regular functions, people know what to expect. With arrow functions, it may be hard to decipher what you are looking at straight away.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Arrow functions, the basics</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 03 Jun 2021 17:47:08 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/arrow-functions-the-basics-2c8h</link>
      <guid>https://dev.to/front_end_shifu_2022/arrow-functions-the-basics-2c8h</guid>
      <description>&lt;h2&gt;
  
  
  Arrow functions
&lt;/h2&gt;

&lt;p&gt;Arrow functions is very simple and short syntax for creating functions, it’s often better than Function Expressions.&lt;br&gt;
 it looks like this:&lt;br&gt;
&lt;em&gt;let func = (arg1, arg2, ..., argN) =&amp;gt; expression&lt;/em&gt;&lt;br&gt;
This creates a function func that accepts arguments arg1..argN, then evaluates the expression on the right side with their use and returns its result.&lt;br&gt;
Let’s see a solid example:&lt;br&gt;
let add = (x, y) =&amp;gt; x + y;&lt;br&gt;
alert( add(1, 2) ); // 3&lt;br&gt;
/* This arrow function is a shorter form of:&lt;br&gt;
let add = function(x, y) {&lt;br&gt;
  return x + y;&lt;br&gt;
};*/&lt;/p&gt;

&lt;p&gt;If we have only one arg, then parentheses around parameters can be ignored, making that even smaller. &lt;br&gt;
e.g.&lt;br&gt;
let num = n =&amp;gt; n * 2;&lt;br&gt;
// roughly the same as: let num = function(n) { return n * 2 }&lt;br&gt;
alert( num(3) ); // 6&lt;/p&gt;

&lt;p&gt;If there are no arguments, parentheses will be empty (but they should be present):&lt;br&gt;
let myName = () =&amp;gt; alert("Talha!");&lt;br&gt;
myName();&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Multiline arrow functions&lt;/em&gt;&lt;br&gt;
let sum = (a, b) =&amp;gt; {  // the curly brace opens a multiline function&lt;br&gt;
  let result = a + b;&lt;br&gt;
  return result; // if we use curly braces, then we need an explicit "return"&lt;br&gt;
};&lt;br&gt;
alert( sum(1, 2) ); // 3&lt;/p&gt;

&lt;p&gt;For now, we can already use arrow functions for one-line actions and callbacks.&lt;br&gt;
I will share more in my upcoming posts.&lt;br&gt;
Thanks for reading &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Function expressions</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 03 Jun 2021 07:26:48 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/function-expressions-33a6</link>
      <guid>https://dev.to/front_end_shifu_2022/function-expressions-33a6</guid>
      <description>&lt;h2&gt;
  
  
  Function expressions3
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;syntax&lt;/em&gt;:&lt;br&gt;
let sayHi = function() {&lt;br&gt;
  alert( "Hello" );&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;look above, the function is created and assigned to the variable clearly , like any other value. No matter how the function is defined, its just a value stored in the variable sayHi.&lt;br&gt;
The meaning of these code samples is the same: "create a function and put it into the variable sayHi".&lt;/p&gt;

&lt;p&gt;We can copy a function to another variable:&lt;/p&gt;

&lt;p&gt;function name() {   // (1) create&lt;br&gt;
  alert( "liliang" );&lt;br&gt;
}&lt;br&gt;
let myName = name;    // (2) copy&lt;br&gt;
myName(); // liliang     // (3) run the copy (it works)!&lt;br&gt;
name(); // liliang    //     this still works&lt;/p&gt;

&lt;p&gt;Why is there a semicolon at the end of function expression?&lt;br&gt;
A function expression is not a codeblock but its an assignment.The semicolon ; is recommended at the end of it, no matter what the value is.&lt;br&gt;
So the semicolon here is not related to the Function Expression itself, it just terminates the statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Callback functions&lt;/strong&gt;&lt;br&gt;
The function should ask the question and, depending on the user’s answer, call yes() or no():&lt;br&gt;
function ask(question, yes, no) {&lt;br&gt;
  if (confirm(question)) yes()&lt;br&gt;
  else no();&lt;br&gt;
}&lt;br&gt;
function showOk() {&lt;br&gt;
  alert( "You agreed." );&lt;br&gt;
}&lt;br&gt;
function showCancel() {&lt;br&gt;
  alert( "You canceled the execution." );&lt;br&gt;
}&lt;br&gt;
// usage: functions showOk, showCancel are passed as arguments to ask&lt;br&gt;
ask("Do you agree?", showOk, showCancel);&lt;/p&gt;

&lt;p&gt;The arguments showOk and showCancel of ask are called callback functions or just callbacks.&lt;/p&gt;

&lt;p&gt;We can use Function Expressions to write the same function much shorter:&lt;/p&gt;

&lt;p&gt;function ask(question, yes, no) {&lt;br&gt;
  if (confirm(question)) yes()&lt;br&gt;
  else no();&lt;br&gt;
}&lt;br&gt;
ask(&lt;br&gt;
  "Do you agree?",&lt;br&gt;
  function() { alert("You agreed."); },&lt;br&gt;
  function() { alert("You canceled the execution."); }&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Here, functions are declared  inside the ask(...) call. They are without  name, so its called anonymous. functions like this are not accessible outside of ask (because they are not assigned to variables), but that’s just what we want here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Expression vs Function Declaration
&lt;/h2&gt;

&lt;p&gt;Function Declaration: a function, declared as a separate statement, in the main code flow.&lt;/p&gt;

&lt;p&gt;// Function Declaration&lt;br&gt;
function sum(x, y) {&lt;br&gt;
  return x + y;&lt;br&gt;
}&lt;br&gt;
A Function Declaration can be called earlier than it is defined&lt;/p&gt;

&lt;p&gt;Function Expression: a function, created inside an expression or inside another syntax construct. Here, the function is created at the right side of the “assignment expression” =:&lt;/p&gt;

&lt;p&gt;// Function Expression&lt;br&gt;
let sum = function(x, y) {&lt;br&gt;
  return x + y;&lt;br&gt;
};&lt;br&gt;
A Function Expression is created when the execution reaches it and is usable only from that moment.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When to choose Function Declaration versus Function Expression?&lt;/em&gt;&lt;br&gt;
As a rule of thumb, when we need to declare a function, the first to consider is Function Declaration syntax. It gives more freedom in how to organize our code, because we can call such functions before they are declared.&lt;/p&gt;

&lt;p&gt;That’s also better for readability, as it’s easier to look up function f(…) {…} in the code than let f = function(…) {…};. Function Declarations are more “eye-catching”.&lt;/p&gt;

&lt;p&gt;…But if a Function Declaration does not suit us for some reason, or we need a conditional declaration , then Function Expression should be used.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Functions</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Tue, 01 Jun 2021 17:34:03 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/functions-2gc5</link>
      <guid>https://dev.to/front_end_shifu_2022/functions-2gc5</guid>
      <description>&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition.&lt;br&gt;
&lt;strong&gt;Function Declaration&lt;/strong&gt;&lt;br&gt;
To create a function we can use a function declaration.It looks like this:&lt;/p&gt;

&lt;p&gt;function showText() {&lt;br&gt;
  alert( 'Hello everyone!' );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;function goes first,then name of function then list of parameters between curly braces(separated by coma)and then main body of the function.&lt;br&gt;
Our new function can be called by its name: showText().&lt;br&gt;&lt;br&gt;
e.g.&lt;br&gt;
function showText() {&lt;br&gt;
  alert( 'Hello everyone!' );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;showText();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local variables&lt;/strong&gt;&lt;br&gt;
A variable declared inside a function can  only be accesd inside that function.we can't acces it from outside .&lt;br&gt;
e.g.&lt;br&gt;
function showMessage() {&lt;br&gt;
 let message = "Hello, I'm JavaScript!"; // local variable&lt;br&gt;
alert( message );&lt;br&gt;
}&lt;br&gt;
showMessage(); // Hello, I'm JavaScript!&lt;br&gt;
alert( message ); // &amp;lt;-- Error! The variable is local to the function&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Outer variables&lt;/strong&gt;&lt;br&gt;
A function can access an outer variable as well.&lt;br&gt;
e.g.&lt;br&gt;
userName = 'Talha';&lt;br&gt;
function showName() {&lt;br&gt;
  let message = 'Hello, ' + userName;&lt;br&gt;
  alert(message);&lt;br&gt;
}&lt;br&gt;
showName(); // Hello, Talha&lt;/p&gt;

&lt;p&gt;The function has full access to the outer variable. It can edit modify it as well.&lt;br&gt;
e.g.&lt;br&gt;
let userName = 'Talha';&lt;br&gt;
function showName() {&lt;br&gt;
let userName = 'cagebreaker';&lt;br&gt;
  let message = 'Hello, ' + userName;&lt;br&gt;
  alert(message);&lt;br&gt;
}&lt;br&gt;
showName(); // Hello, cagebreaker&lt;/p&gt;

&lt;p&gt;note:The outer variable is only used if there’s no local one.&lt;/p&gt;

&lt;p&gt;If a same-named variable is declared inside the function then it ignore the outer one and use local variable. &lt;br&gt;
e.g.&lt;br&gt;
let userName = 'Talha';&lt;br&gt;
function showName() {&lt;br&gt;
let userName = 'cagebreaker';&lt;br&gt;
  let message = 'Hello, ' + userName;&lt;br&gt;
  alert(message);&lt;br&gt;
}&lt;br&gt;
showName(); // Hello, cagebreaker&lt;br&gt;
alert( userName ); // Talha, unchanged, the function did not access the outer variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global variables&lt;/strong&gt;&lt;br&gt;
Variables declared outside of any function, such as the outer userName in the code above, are called global.&lt;br&gt;
Global variables are visible from any function (unless shadowed by locals).&lt;br&gt;
&lt;em&gt;Note&lt;/em&gt;:It’s a good practice to minimize the use of global variables. Modern code has few or no globals. Most variables reside in their functions. Sometimes though, they can be useful to store project-level data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;br&gt;
It's also called function argument.&lt;br&gt;
We can pass arbitrary(any) data to functions using parameters.&lt;br&gt;
e.g. look at the example below the function has two parameters: fullName and LastName:&lt;/p&gt;

&lt;p&gt;function showMessage(fullname, lastName) { // arguments: fullName, LastName&lt;br&gt;
alert(fullName + ': ' + LastName);&lt;br&gt;
}&lt;br&gt;
showMessage('Talha', 'Khan'); // Talha: Khan! (&lt;em&gt;)&lt;br&gt;
showMessage('Hasnian', "Afridi:)&amp;gt;"); // Hasnain:Afridi (&lt;/em&gt;&lt;em&gt;)&lt;br&gt;
When the function is called in lines (&lt;/em&gt;) and (**), the given values are copied to local variables from and text. Then the function uses them.&lt;br&gt;
this is all for now I will share more in my upcomming posts&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>switch statement</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Tue, 01 Jun 2021 05:20:29 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/switch-statement-3dja</link>
      <guid>https://dev.to/front_end_shifu_2022/switch-statement-3dja</guid>
      <description>&lt;p&gt;&lt;strong&gt;syntax&lt;/strong&gt;:&lt;br&gt;
switch(x) {&lt;br&gt;
  case 'value1':  // if (x === 'value1')&lt;br&gt;
    ...&lt;br&gt;
    [break]&lt;/p&gt;

&lt;p&gt;case 'value2':  // if (x === 'value2')&lt;br&gt;
    ...&lt;br&gt;
    [break]&lt;/p&gt;

&lt;p&gt;default:&lt;br&gt;
    ...&lt;br&gt;
    [break]&lt;br&gt;
}&lt;br&gt;
&lt;strong&gt;Switch&lt;/strong&gt;&lt;br&gt;
Switch statement is a part of JavaScript "Conditional" Statements, which are used to perform different actions based on different conditions. Use switch to select one of many blocks of code to be executed. ... without break, if condition is true the all the next block will be executed .If no case is matched then the default code is executed (if it exists).&lt;/p&gt;

&lt;p&gt;e.g.&lt;br&gt;
let add = 1 + 3;&lt;/p&gt;

&lt;p&gt;switch (add) {&lt;br&gt;
  case 3:&lt;br&gt;
    alert( 'small' );&lt;br&gt;
    break;&lt;br&gt;
  case 4:&lt;br&gt;
    alert( 'Correct' );&lt;br&gt;
    break;&lt;br&gt;
  case 5:&lt;br&gt;
    alert( 'big' );&lt;br&gt;
    break;&lt;br&gt;
  default:&lt;br&gt;
    alert( "no values" );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;In the above example  switch start to compare add to first case which is 3 .The match fails now it will the second case which is 4.well That's the correct match.so the execution start from match 4 until the nearest break.&lt;br&gt;
Note:If there is no break then the execution continues with the next case without any checks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Grouping of “case”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if we want the same code to run for case 3 and case 5:&lt;/p&gt;

&lt;p&gt;let add = 3||5;&lt;/p&gt;

&lt;p&gt;switch (add) {&lt;br&gt;
  case 4:&lt;br&gt;
    alert('wrong!');&lt;br&gt;
    break;&lt;br&gt;
  case 3: // (*) grouped two cases&lt;br&gt;
  case 5:&lt;br&gt;
    alert('right!');&lt;br&gt;
    alert("3 or 5");&lt;br&gt;
    break;&lt;br&gt;
  default:&lt;br&gt;
    alert('not matched" );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;I hope you will get the idea from a  example above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type matters:&lt;/strong&gt;&lt;br&gt;
Let’s make a point of that the equality check is always strict. The values must be of the same type to match.&lt;/p&gt;

&lt;p&gt;e.g.&lt;/p&gt;

&lt;p&gt;let n= prompt("Enter a  number");&lt;br&gt;
switch (n){&lt;br&gt;
  case '0':&lt;br&gt;
  case '1':&lt;br&gt;
    alert( 'One or zero' );&lt;br&gt;
    break;&lt;/p&gt;

&lt;p&gt;case 2:&lt;br&gt;
    alert( 'not a string ');&lt;br&gt;
    break;&lt;/p&gt;

&lt;p&gt;case 3:&lt;br&gt;
    alert( 'Nnot a string');&lt;br&gt;
    break;&lt;br&gt;
  default:&lt;br&gt;
    alert( 'no match');&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;For 0, 1, the first alert runs.&lt;/p&gt;

&lt;p&gt;But for  2 and 3 the result of the prompt is a string "2" "3", which is not strictly equal === to the number 2 or 3.So we’ve got a dead code in case  in  both Thus default variant will execute.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>loop skipping parts,break ,continue </title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Fri, 28 May 2021 17:49:00 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/loop-skipping-parts-break-continue-1hmc</link>
      <guid>https://dev.to/front_end_shifu_2022/loop-skipping-parts-break-continue-1hmc</guid>
      <description>&lt;p&gt;&lt;strong&gt;for loop skipping part:&lt;/strong&gt;&lt;br&gt;
any part of for loop can be skipped&lt;/p&gt;

&lt;p&gt;we can omit begin if we don’t need to do anything at the loop start.&lt;/p&gt;

&lt;p&gt;Like here:&lt;br&gt;
let i = 0; // we have i already declared and assigned&lt;br&gt;
for (; i &amp;lt; 3; i++) { // no need for "begin"&lt;br&gt;
  alert( i ); // 0, 1, 2&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;We can also remove the step part:&lt;br&gt;
let i = 0;&lt;br&gt;
for (; i &amp;lt; 3;) {&lt;br&gt;
  alert( i++)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;We can actually remove everything, creating an infinite loop:&lt;br&gt;
for (;;) {&lt;br&gt;
  // repeats without limits&lt;br&gt;
} );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;&lt;br&gt;
the two for semicolons ; must be present. Otherwise, there would be a syntax error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Break&lt;/strong&gt;&lt;br&gt;
we can break loop any time using the special break directive.&lt;/p&gt;

&lt;p&gt;e.g.&lt;/p&gt;

&lt;p&gt;let sum = 0;&lt;br&gt;
while (true) {&lt;br&gt;
  let value = +prompt("Enter a number", '');&lt;br&gt;
  if (!value) break; // (*)&lt;br&gt;
  sum += value;&lt;br&gt;
}&lt;br&gt;
alert( 'Sum: ' + sum );&lt;/p&gt;

&lt;p&gt;In the above example  if none of value is entered or cancled The break directive is activated at the line (*) . It stops the loop immediately, passing control to the first line after the loop. Namely, alert.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;continue&lt;/strong&gt;&lt;br&gt;
The continue directive is a “lighter version” of break. It doesn’t stop the whole loop. Instead, it stops the current iteration and forces the loop to start a new one (if the condition allows).&lt;/p&gt;

&lt;p&gt;We can use it if we’re done with the current iteration and would like to move on to the next one.&lt;/p&gt;

&lt;p&gt;e.g.&lt;br&gt;
loop  uses continue to output only odd values:&lt;/p&gt;

&lt;p&gt;for (let i = 0; i &amp;lt; 10; i++) {&lt;br&gt;
  // if true, skip the remaining part of the body&lt;br&gt;
  if (i % 2 == 0) continue;&lt;br&gt;
  alert(i); // 1, then 3, 5, 7, 9&lt;br&gt;
}&lt;br&gt;
For even values of i, the continue directive stops executing the body and passes control to the next iteration of for (with the next number). So the alert is only called for odd values.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>loops </title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Fri, 28 May 2021 17:05:29 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/loops-4eig</link>
      <guid>https://dev.to/front_end_shifu_2022/loops-4eig</guid>
      <description>&lt;p&gt;Loops are a way to repeat the same code multiple times.&lt;br&gt;
&lt;strong&gt;while loop&lt;/strong&gt;&lt;br&gt;
syntax:&lt;br&gt;
while (condition) {&lt;br&gt;
  // code&lt;br&gt;
  // so-called "loop body"&lt;br&gt;
}&lt;br&gt;
when the condition is true ,while  loop can be executed.&lt;/p&gt;

&lt;p&gt;let z = 0;&lt;br&gt;
*while (z &amp;lt; 4) { &lt;br&gt;
  alert( z );&lt;br&gt;
  z++;&lt;br&gt;
}&lt;br&gt;
in the above example it will show 0 then 1 the 2 then 3 and  z&amp;lt;4  which is false so the loop will stop. *&lt;/p&gt;

&lt;p&gt;A single execution of the loop body is called an iteration. &lt;br&gt;
if z++ were missing then the loop would execute infinite times.&lt;br&gt;
Any expression or variable can be a loop condition, not just comparisons: the condition is evaluated and converted to a boolean by while.&lt;/p&gt;

&lt;p&gt;For instance, a shorter way to write while (i != 0) is while (i):&lt;/p&gt;

&lt;p&gt;let i = 3;&lt;br&gt;
while (i) { // when i becomes 0, the condition becomes falsy, and the loop stops&lt;br&gt;
  alert( i );&lt;br&gt;
  i--;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The “do…while” loop&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;syntax:&lt;/em&gt;&lt;br&gt;
do {&lt;br&gt;
  // loop body&lt;br&gt;
} while (condition);&lt;/p&gt;

&lt;p&gt;The loop will first execute the body, then check the condition, and, while it’s truthy, execute it again and again.&lt;br&gt;
e.g.&lt;br&gt;
let z = 0;&lt;br&gt;
do {&lt;br&gt;
  alert( z );&lt;br&gt;
  z++;&lt;br&gt;
} while (z&amp;lt;3);&lt;/p&gt;

&lt;p&gt;This form of syntax should only be used when you want the body of the loop to execute at least once regardless of the condition being truthy. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;for loop&lt;/strong&gt;&lt;br&gt;
syntax:&lt;br&gt;
for (begin; condition; step) {&lt;br&gt;
  // ... loop body ...&lt;br&gt;
}&lt;br&gt;
it's complex and most commonly used loop.&lt;br&gt;
It begin executes once, and then it iterates: after each condition test, body and step are executed.&lt;/p&gt;

&lt;p&gt;// for (let z = 0; z &amp;lt; 2; z++) alert(i)&lt;/p&gt;

&lt;p&gt;// run begin&lt;br&gt;
let z = 0&lt;br&gt;
// if condition → run body and run step&lt;br&gt;
if (z &amp;lt; 2) { alert(z); z++ }&lt;br&gt;
// if condition → run body and run step&lt;br&gt;
if (z &amp;lt; 2) { alert(z); z++ }&lt;br&gt;
// ...finish, because now z == 2&lt;/p&gt;

&lt;p&gt;Inline variable declaration&lt;br&gt;
if variable in declared in loop is called inline loop&lt;/p&gt;

&lt;p&gt;for (let i = 0; i &amp;lt; 3; i++) {&lt;br&gt;
  alert(i); // 0, 1, 2&lt;br&gt;
}&lt;br&gt;
alert(i); // error, no such variable&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>logical operater(Not !)</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 27 May 2021 11:07:35 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/logical-operater-not-31gn</link>
      <guid>https://dev.to/front_end_shifu_2022/logical-operater-not-31gn</guid>
      <description>&lt;h2&gt;
  
  
  ! (NOT)
&lt;/h2&gt;

&lt;p&gt;Converts the operand to boolean type: true/false.&lt;br&gt;
Returns the inverse value.&lt;br&gt;
he syntax is pretty simple:  result = !value;&lt;br&gt;
e.g.&lt;br&gt;
alert( !true ); // false&lt;br&gt;
alert( !0 ); // true&lt;/p&gt;

&lt;p&gt;A double NOT !! is sometimes used for converting a value to boolean type:&lt;br&gt;
e.g&lt;br&gt;
alert( !!"talha" ); // true&lt;br&gt;
alert( !!0 ); // false&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>logical operater(&amp;&amp;And)</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 27 May 2021 10:57:00 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/logical-operater-and-463b</link>
      <guid>https://dev.to/front_end_shifu_2022/logical-operater-and-463b</guid>
      <description>&lt;h2&gt;
  
  
  &amp;amp;&amp;amp; (AND)
&lt;/h2&gt;

&lt;p&gt;In classical programming, AND returns true if both operands are true.otherwise its false.&lt;/p&gt;

&lt;p&gt;alert( true &amp;amp;&amp;amp; true ); // true&lt;br&gt;
alert( false &amp;amp;&amp;amp; true ); // false&lt;br&gt;
alert( true &amp;amp;&amp;amp; false ); // false&lt;br&gt;
alert( false &amp;amp;&amp;amp; false ); // false&lt;br&gt;
e.g.&lt;br&gt;
prompt(1&amp;amp;&amp;amp;0); //return 0&lt;/p&gt;

&lt;p&gt;Now lets talk about multiple AND values:&lt;br&gt;
result = value1 &amp;amp;&amp;amp; value2 &amp;amp;&amp;amp; value3;&lt;br&gt;
The AND &amp;amp;&amp;amp; operator does the following:&lt;/p&gt;

&lt;p&gt;Evaluates operands from left to right.&lt;br&gt;
For each operand, converts it to a boolean. If the result is false, stops and returns the original value of that operand.&lt;br&gt;
If all operands have been evaluated (i.e. all were truthy), returns the last operand.&lt;/p&gt;

&lt;p&gt;e.g.&lt;br&gt;
prompt(null &amp;amp;&amp;amp; 1 &amp;amp;&amp;amp; 2);// output is null.&lt;br&gt;
prompt(1 &amp;amp;&amp;amp; 2 &amp;amp;&amp;amp; "ppp");// output is ppp.&lt;/p&gt;

&lt;p&gt;let person1=0;&lt;br&gt;
let person2;&lt;br&gt;
let person3='talha';&lt;br&gt;
alert(person1||person2||person3||'no one');*&lt;br&gt;
above output is 0.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Logical operators(|| OR)</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 27 May 2021 09:20:00 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/logical-operators-or-11k3</link>
      <guid>https://dev.to/front_end_shifu_2022/logical-operators-or-11k3</guid>
      <description>&lt;h3&gt;
  
  
  || (OR)
&lt;/h3&gt;

&lt;p&gt;the logical OR Return true If any of its arguments are true otherwise it returns false..&lt;br&gt;
e.g.&lt;br&gt;
alert( true || true );   // true&lt;br&gt;
alert( false || true );  // true&lt;br&gt;
alert( true || false );  // true&lt;br&gt;
alert( false || false ); // false&lt;/p&gt;

&lt;p&gt;If an operand is not a boolean, it’s converted to a boolean for the evaluation.&lt;/p&gt;

&lt;p&gt;For instance, the number 1 is treated as true, the number 0 as false&lt;br&gt;
e.g.&lt;br&gt;
if (1 || 0) { &lt;br&gt;
  alert( 'truthy!' );&lt;br&gt;
}&lt;br&gt;
in above the output is truthy.cause true||false return True.&lt;/p&gt;

&lt;p&gt;Now lets talk about multiple OR’ed values:&lt;br&gt;
result = value1 || value2 || value3;&lt;/p&gt;

&lt;p&gt;The OR || operator does the following:&lt;br&gt;
Evaluates operands from left to right.&lt;br&gt;
For each operand, converts it to boolean. If the result is true, stops and returns the original value of that operand.&lt;br&gt;
If all operands have been evaluated (i.e. all were false), returns the last operand.&lt;br&gt;
e.g.&lt;br&gt;
alert(''||0||1);//return 1 which is first truthy value&lt;br&gt;
alert(null,0,undefined);// all falsy ,return last value.&lt;br&gt;
*&lt;br&gt;
let person1='';&lt;br&gt;
let person2;&lt;br&gt;
let person3='talha';&lt;br&gt;
alert(person1||person2||person3||'no one');*&lt;br&gt;
above output is talha.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Falsy values</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Thu, 27 May 2021 06:48:43 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/falsy-values-4342</link>
      <guid>https://dev.to/front_end_shifu_2022/falsy-values-4342</guid>
      <description>&lt;p&gt;what are truthy and falsy values?&lt;br&gt;
&lt;strong&gt;truthy values&lt;/strong&gt;:&lt;br&gt;
these values are actually not a boolean values but they act like True .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;falsy values&lt;/strong&gt;:&lt;br&gt;
These values are actually not false(boolean) but they act as a false. it includes 0,null,"",undefined,false,NAN.&lt;/p&gt;

&lt;p&gt;// if the first operand is truthy,&lt;br&gt;
// AND returns the second operand:&lt;br&gt;
alert( 1 &amp;amp;&amp;amp; 0 ); // 0&lt;br&gt;
alert( 1 &amp;amp;&amp;amp; 5 ); // 5&lt;/p&gt;

&lt;p&gt;// if the first operand is falsy,&lt;br&gt;
// AND returns it. The second operand is ignored&lt;br&gt;
alert( null &amp;amp;&amp;amp; 5 ); // null&lt;br&gt;
alert( 0 &amp;amp;&amp;amp; "no matter what" ); // 0&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: All values are truthy unless they are defined as falsy.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>String obj:</title>
      <dc:creator>front_end_shifu_2022</dc:creator>
      <pubDate>Tue, 25 May 2021 19:04:18 +0000</pubDate>
      <link>https://dev.to/front_end_shifu_2022/string-obj-1ki0</link>
      <guid>https://dev.to/front_end_shifu_2022/string-obj-1ki0</guid>
      <description>&lt;h1&gt;
  
  
  string Objects
&lt;/h1&gt;

&lt;p&gt;in js strings are objects.&lt;br&gt;
The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.&lt;br&gt;
Use the following syntax to create a String object :&lt;br&gt;
let value = new String(string);&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;string property&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;length Returns the length of the string.&lt;br&gt;
e.g.&lt;br&gt;
&lt;em&gt;let  human = " john pepper";&lt;br&gt;
human.length;&lt;br&gt;
let length = human.lenght;&lt;br&gt;
console.log(human.length);&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  String Methods
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CharAt():
&lt;/h3&gt;

&lt;p&gt;return the character at specified index.&lt;br&gt;
&lt;em&gt;let  human = " john pepper";&lt;br&gt;
console.log(human.charAt(1))  // o&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  indexOf():
&lt;/h3&gt;

&lt;p&gt;Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.&lt;br&gt;
&lt;em&gt;let  human = " john pepper";&lt;br&gt;
console.log(human.indexOf(e));  // 6&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  toLowerCase():
&lt;/h3&gt;

&lt;p&gt;Returns the calling string value converted to lower case.&lt;br&gt;
*let  human = " John Pepper";&lt;br&gt;
console.log(human.toLowerCase());  //john pepper&lt;/p&gt;

&lt;h3&gt;
  
  
  toUpperCase():
&lt;/h3&gt;

&lt;p&gt;Returns the calling string value converted to upperCase.&lt;br&gt;
&lt;em&gt;let  human = " John Pepper";&lt;br&gt;
console.log(human.toUpperCase()); //JOHN PEPPER&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  slice()
&lt;/h3&gt;

&lt;p&gt;Extracts a section of a string and returns a new string.&lt;br&gt;
&lt;em&gt;let  human = " John Pepper";&lt;br&gt;
console.log(human.slice(1,4)); //OHN&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is all for now I'll share more in my upcoming posts.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
