Professional Documents
Culture Documents
Java Notes
Java Notes
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)
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"
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.
//*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.
@ 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 ..
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"
{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 ]
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..
var a = 12;
bar b = a;
b = b+2;
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
{ 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!}
}
if("12"){
console.log{hey}
}
else{
console.log{bey!}
}
if("-1"){
console.log{hey}
}
else{
console.log{bey!}
}
RESULT = hey (right rhega)
if("0"){
console.log{hey}
}
else{
console.log{bey!}
}
if("NAN"){
console.log{hey}
}
else{
console.log{bey!}
}
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]
var prev = 0;
var current = 1;
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
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.
console.log(friends[-1]);
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 = [];
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 )
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 //
arr.forEach(function(val){
console.log(val);
})
//agr arry ki value ko multiple(*) ya minus (-) krvani h to log () me sign use krte h
arr.forEach(function(val){
console.log(val*2); / console.log(val-2);
})
other example
arr.forEach(function(val){
console.log("hello,"+ val);
})
Results=> hello,Dharm
hello,Ram
hello,shyam
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
//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//