This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fun() { | |
console.log("hello world"); | |
} | |
fun(); | |
fun.greeting = "Hello from property"; | |
console.log(fun.greeting) //=> "Hello from property" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myFunction = function [name]([param1[, param2[, ..., paramN]]]) { | |
statements | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mammal | |
def breathe | |
puts "inhale and exhale" | |
end | |
end | |
class Cat < Mammal | |
def speak | |
puts "Meow" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapForEach(arr, fn) { | |
const newArr = []; | |
for (let i=0; i < arr.length; i++) { | |
newArr.push( | |
fn(arr[i]) | |
); | |
}; | |
return newArr; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating the second prototype | |
const proto2 = function () {}; | |
proto2.prop3 = "proto 2's property" | |
// Creating the first prototype | |
const proto1 = Object.create(proto2) | |
proto1.prop2 = 'protos property'; | |
const obj = Object.create(proto1); | |
obj.prop = 'object\'s property'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating the first prototype | |
const proto1 = function() {}; | |
proto1.prop2 = 'protos property'; | |
const obj = Object.create(proto1); | |
obj.prop = 'object\'s property'; | |
console.log(obj.prop); | |
console.log(obj.prop2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = function() {}; | |
obj.prop = 'object\'s property'; | |
console.log(obj.prop); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buttton.addEventListener(‘click, function() { | |
this.classList.toggle(‘on’); //=> error!!! This is defined globally. | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const button = document.querySelector(‘.button’); | |
buttton.addEventListener(‘click, () => { | |
this.classList.toggle(‘on’); //=> error!!! This is defined globally. | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const results = winners.map((winner, i) => ({name: winner, race: race, place: i})); |
NewerOlder