You are on page 1of 10

var ans = prompt("dar");

console.log("chahcha");
alert("cgkldf");
console.error("notice");
console.warn("no why");

                                 
                                   : - COLON
                                   ; - semicolon
                                   & - and
                                   ! - negation
                                   () - small braket
                                   {} - curly braket
                                   [] - square
                                   -  - minus ya desh
                                   ~ -  tilde

//var = variable ko var likhte h...  veriable ki help se program me value put krte h or chng bhi kr skte h...

                                          //variable

//jab bhi program life cycle me data store krna ho, aur hm chate ho vo data end tk rhe , usko save karne k liye we can use variables...

//kabhi game khela ... mario/bounce ball=> usme kuch variable hote jese niche use kiye h vo value stating se end tk rhti h kuch value hoti
h (0/1/2/3/4 etc)

Mario => starting

hero - score = 0
       lives = 3
 
game over=>
            score = 45
            lives = 0
           
  $ => java Script me variab  banane ke liye pehle var likhna h fir name( jo variable ka nam likhna ho vo) than koi value number or
alphabates...        
                   {Example}
  var score = 0;
  var lives = 2;
  var chacha = "badiya!";
  var chachi = "nice";
  kuch bhi likh skte h

  *//=> value ko single quote me ('')....../ ya double quote me (" ") koi error ni ati or baki language me error ati h ...  Java khti h 'a'
ek charecter ko single quote me or ek se jada word ko double quate me "apple".....  but    JavaScript me anythink you want!

          {Example}

          'a'
          'apple'
          "a"
          "apple"

          // variable likhne ka tarika ..


           var a = 12;  (correct)
           var = 12;   (error)   program var ko search krage, use mil jayega but jb uske bad vo name search karegaa to ni milega so vo
error dega...

           var const = 12; (error)=> name ki jgh const likha h jo ek reserved keyword h isliye vo glt h
           var consta = 12; (CORRECT)

           // har language me kuchh words reserved hote hai matlab ki sp unhe use nai kr skate as a name, hum unhe keywords khte hai.

                              ( { [ "TOPICE = DECLARATION VS INITIALIZATON" ] } )

              //*declaration  mtlb kuch batana bs for   examp, 100 logo me koi pgl hai vo kon h ye ni bataya ise declaration khte h .
             
              //*INITIALIZATION mtlb jisko decleard kia h use value dena like "a" hai is declaration or "a" ki koi value h vo
initialization.

              var a; => declaration


              a = 22 => initialization
              a = 12 => its not initilation its chng value of initilation

              var a = 12; => declaration+ initiation = complete variable

              @ variable only 1 bar banta h nxt time use likhna hai to use uske nam se likha jataa h...

             
                                          //constant  

                  c0nstat is that which cannot be chng but its value  can be updated... jese pai ki value same rhti h ..                  

              // you cannot "just" DECLARE constant as variable   example

              const a;  // this is error because cannt add value on it not be chng variable only value chng not variable and here only type
variable "a"

              const a = 12; right

                                   ///////  TYPES => PREMITIVES & REFRENCES  //////

             {ESI VALUE jo copy karne pr same copy  ho jati h permitives khlati h & ese value jinhe copy krte h to vo copy ni hoti bs unka
add . copy hota h REFRENCES bolte h }
             
             [almost sabhi value copy ho jati bs 3 braket ki value ko chod kr  vo 3 h => () function , method / {} object , scope / [ ]
array inke under ki value kabhi copy ni hogi bs inka add . copy hota h ]

             example ..of permitive .. ..$   var a = 12;


                                                  var b = a;

               var a =[1,2,3];
               var b = a;        REFRENCES exple h ye  
               
               b.pop();  pop se "b" ke last ki value hat jana chahiye but "b" ke sath "a" se bhi remove ho jati h kyoki ye REFRENCES wali
value hai or ye copy ni hoti inka add . copy hota isliye jo main value hoti h usi me chng hoga always..

               b.pop(); last ki ek value remove krta h


 
               b.shift(); frist value ko remove krta h

               b.unshift(); frist value ke pehle variable add krta h

               b.push();   last value ke bad variable add krta h

               var a = 12;
               bar b = a;

               b = b+2;

               results me a=12 , b =14

                                          //// CONDITIONALS ////

                                  FOR AND FOREACH LOOPS


                                 
        if => agar
        eles => nahi to
       
        example   agr a 10 se bda hai to   hey  print   kro nahi to   bey    print   kro
                       
                     var a = 12;

                if(a>10){
                     console.log("hey");
                }
                else{
                     console.log(bey);
                }
    if("") => function ke andr kuch bhi likh skta h user  jo na to ture hai na hi flase h isliye     banane wale ne 2 catogery         me  
saprate kia ture value and flase value          

                if("chahcha") => not right not wrong

               { 0/null/not a number (NAN)/ undefind} => all -ve terms function ke andr false value me count hogi ye predefine hoti h and
loop not run

               {-1/-2/1/2/3} nagative and positive number is true value and loop will run

               example////

               if("chahcha"){
                     console.log{hey}
               }
               else{
                     console.log{bey!}
               }

               RESULT = hey (right rhega)

               if("12"){
                     console.log{hey}
               }
               else{
                     console.log{bey!}
               }

               RESULT = hey (right rhega)

               if("-1"){
                     console.log{hey}
               }
               else{
                     console.log{bey!}
               }
               RESULT = hey (right rhega)

               if("0"){
                     console.log{hey}
               }
               else{
                     console.log{bey!}
               }

               RESULT = bey! (wrong rhega)

               if("NAN"){
                     console.log{hey}
               }
               else{
                     console.log{bey!}
               }

               RESULT = bey! (wrong rhega)

                                   //// loops ///

                    for(start;end;change;)    
                   
                    for(var i = 1;i<12; i++){ }
i++ => isse "i" ki value 1+ hogi hr bar [ i+ jesa kuch ni hota alwys i++ hoga]

                        "i" ki value agr +2 se badani h to (i = i+2 or i+ =2 ( jese i- =2/ i* =2))

                      ////  question => print kro 0 to 50 /////

                      for(var i =0; i<51; i++){}

                       ////  question => print kro 0 1 1 2 3 5 8 13 21 /////

                                          [Fibonacci series bolte h 👇 ise]


                     
                      console.log(0);
                      console.log(1);

                      var prev  = 0;
                      var current = 1;

                      for(var i =1; i<8; i++){


                        var next = prev+current;
                        console.log(next);

                        prev = current;
                        current =next;
                      }

      ##### agr series me gradualy chng ho rha h to loop banana h but but agr vha kuch bhi nmber h to fir series solve kro pta kro ky      
parttren h . than code kro or ese case me loop bs printing ke liye use hoga baki funtion khud ko soch kr banaana h

                  ?// array => ek se jaada values hold karne ke liye we use array.

                  var friends = harsh, harshita, harshit, chaman;  => ye glt h error ajayega

                  var friends = ["harsh, harshita, harshit, chaman"]; always jo define nahi h use " " inverted koma me likhe

                      console.log(friends[10])  => error a jayega kyoki esa index nahi h

             important =>>>     [array me index or position hote h index always 0 se count hoga or position bolenge to 1 se hi count krna h
. jese hme (harsh) print krna h to  console.log(friends[0]) me "0" likhna hoga vo position "1" pr h but print ke time index se print hota h
isliye 0 likh .  ]   example ==>> array ke andr elements 10 h to index or print value 9 tk hi hogi 10 print krenge to undefind error ayega.

             friends.pop(); last ki ek value remove krta h


 
             friends.shift(); frist value ko remove krta h
   
             friends.unshift("harry"); frist value ke pehle variable add krta h
   
             friends.push("dev");   last value ke bad variable add krta h

                  //// {array me hm [-1] ki  value bhi print krva skte h } ///

                  friends[-1] = "your dad";

                  console.log(friends[-1]);

var arr = [];

                  arr.push("hey");  => ek value add krega last me           isme =>  var arr = [];
                  arr.push("hello"); => ek or value add krega last me         isme =>  var arr = [];
                  arr.pop();        =>   ek  value remove  krega last me           isme =>  var arr = [];
                  arr.shift();      =>   ek  value remove  krega frist me           isme =>  var arr = [];
                  arr.unshift("hey");     => ek or value add krega frist me         isme =>  var arr = [];

                                       //////// foreach loop ////

             arr.forEach(function abcd(value){})    => error ayegi kyoki name nahi hota function ke bad  
             
             arr.forEach(function(value){})    => right ( value ki jgh kuch bhi likh skte h jo var ka nam hoga vo )

             var arr = [1,2,3];

             arr.forEach(function(val){
                  console.log(hey);
             })              
                   console.log(); me jo likhoge vo print ho jayega .$

                   //agr arry ki value print krvani h to log () me vhi likhna h jo funtion ke () me likha ho   //

                   var arr = [1,2,3];

                   arr.forEach(function(val){
                        console.log(val);
                   })

                   //agr arry ki value ko multiple(*) ya minus (-)  krvani h to log () me sign use krte h

                   var arr = [1,2,3];

                   arr.forEach(function(val){
                        console.log(val*2);        /  console.log(val-2);
                   })

                   other example

                   var arr = ["Dharm","Ram","shaym"];

                   arr.forEach(function(val){
                        console.log("hello,"+ val);
                   })

                   Results=> hello,Dharm
                              hello,Ram
                              hello,shyam

                              ///// Learning list ////

                              alert  
                              promt
                              console.log
                              error
                              warnnig
                              variable
                              constant
                              types  
                              declaration and initialization
                              if else  else if
                              loops - for , foreach
                              array - push, pop, shift, unshift
                              function
                              object, this, call, apply, bind

                        ///// Function - 6 types /////

           //block of code jo baar barr use kia jaa skta hai jab jarurt pade
           
           // funtion ko direct run nahi krte isko run krne ke liye ek button bnate h .bs use button ko apply kro jaha code chalana h ek
code ko bar bar chala skte h alg alg jgh pr ... code ko bna kr uska nam likh do  example niche h

           function pineapple(){
            console.log("p");
            console.log("i");
            console.log("n");
            console.log("e");
            console.log("a");
            console.log("p");
            console.log("p");
            console.log("l");
            console.log("e");
     
           }
// abhi code ni chalega jb tk run krne ke liye bottun ni bna dete//

            pineapple();          => this is a buttton iske vjh se code chl jayega

You might also like