Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //logical AND(&&) OR(||) operator
- //logical Not(!)
- //short circuit
- //if, else, else if
- //ternary
- //switch
- //truthy and falsy value
- //Boolean (true , false)
- //truthy or falsy
- //falsy value
- //false
- //0
- //''
- //undefined
- //null
- //NaN
- //!(logical not)
- // console.log(!!false)
- // console.log(!!'')
- // console.log (Boolean(''))
- //truthy (other than falsy value)
- //if else if else
- // const age = 17
- // if(age >= 18){
- // console.log('you can vote')
- // }else{
- // console.log('you can not vote')
- // }
- //alternative (ternary)
- // const result = age >= 18 ? 'you can vote' : 'you can not vote'
- // console.log(result)
- // age === 18 = true
- //18 === true
- // console.log(age >= 18 && age)
- // switch(true){
- // case age >= 18:
- // console.log('you can vote')
- // break
- // case 19:
- // console.log('you are 19')
- // break
- // default:
- // console.log('unknown')
- // }
- //logical AND(&&) OR(||) operator
- //&& - result true when every part is true
- //otherwise false
- //short circuit
- // console.log(true && true && true)
- // console.log(true && false && true) //short circuit
- // console.log(true && false && false) //short circuit
- // const showMessage = false
- // console.log(showMessage && 'Hello world')
- //logical OR(||)
- // if any part is true result will be true
- //otherwise false
- // console.log(false || false || true)
- // console.log(false || false || false)
- // console.log(false || true || false) //short circuit
- // console.log(true || true || true)//short circuit
- // const showMessage = false
- // console.log(showMessage || 'Hello world')
- // console.log(showMessage || '')
- //loop -repetition
- // for(init; condition; incrementordecrement+){
- // //output
- // }
- //for loop
- // for(let i = 0; i < 10; i++ ){
- // console.log(`Hello world ${i + 1} ${i + 1 < 2 ? 'time': 'times'}`)
- // }
- //while loop
- // let i = 0
- // while(i < 10){
- // console.log(`Hello world ${i + 1} ${i + 1 < 2 ? 'time': 'times'}`)
- // i++
- // }
- //10 times
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
- // console.log('Hello world')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement