Skip to content

Instantly share code, notes, and snippets.

View himeshvats19's full-sized avatar

Himesh Vats himeshvats19

View GitHub Profile
var link = function(height = 50, color = 'red', url = 'http://azat.co') {
...
}
var link = function (height, color, url) {
var height = height || 50
var color = color || 'red'
var url = url || 'http://azat.co'
...
}
function createCounter() {
let counter = 0
const myFunction = function() {
counter = counter + 1
return counter
}
return myFunction
}
const increment = createCounter()
const c1 = increment()
let val = 7
function createAdder() {
function addNumbers(a, b) {
let ret = a + b
return ret
}
return addNumbers
}
let adder = createAdder()
let sum = adder(val, 8)
let val1 = 2
function multiplyThis(n) {
let ret = n * val1
return ret
}
let multiplied = multiplyThis(6)
console.log('example of scope:', multiplied)
{
"this": 1,
"is": 1,
"a": 2,
"class": 1,
"of": 1,
"advance": 1,
"javascript": 2,
"from": 1,
...
array.find(function(currentValue, index, arr),thisValue)
{
const hello = 'Hello ICFers!'
console.log(hello) // 'Hello ICFers!'
}
console.log(hello) // Error, hello is not defined
function sayHello () {
const hello = 'Hello ICFers!'
console.log(hello)
}
sayHello() // 'Hello ICFers!'
console.log(hello) // Error, hello is not defined
function sayHello () {
const hello = 'Hello CSS-Tricks Reader!'
console.log(hello)
}
sayHello() // 'Hello CSS-Tricks Reader!'
console.log(hello) // Error, hello is not defined