Created
November 30, 2020 14:56
-
-
Save atsushi-kitazawa/bf6d4902ee96740dc10887e0d7b29c23 to your computer and use it in GitHub Desktop.
my javascript study code.
This file contains 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
// stdout | |
var name = "hoge" | |
console.log("hello "+ name) | |
// create object | |
const person = { | |
name: ['Bob', 'Smith'], | |
age: 33, | |
gender: 'male', | |
bio: function() { | |
return this.name[0] + ' ' + this.name[1] + ' is ' + this.age + ' years old.' | |
} | |
}; | |
console.log(person.name) | |
console.log(person.name[0]) | |
console.log(person.age) | |
console.log(person.bio()) | |
console.log(person['name']) | |
// variable access | |
var key = 'name' | |
console.log(person[key]) | |
// constructor function | |
function Person(name) { | |
this.name = name; | |
this.greeting = function() { | |
return 'Hi! I\'m ' + this.name; | |
}; | |
} | |
let person1 = new Person('Bob'); | |
let person2 = new Person('Sarah'); | |
console.log(person1.greeting()); | |
console.log(person2.greeting()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment