Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ES6 Arrows Example.
- let evens = [0,2,4,6,8,10,12,14,16,18,20];
- let odds = evens.map(v => v + 1);
- let nums = evens.map((v,i) => v + i);
- let pairs = evens.map(v => ({even: v , odd : v + 1}));
- document.write(odds + '<br/>');
- document.write(nums + '<br/>');
- document.write(JSON.stringify(pairs) + '<br/>');
- let fives = [];
- nums.forEach(v => {
- if(v % 5 === 0){
- fives.push(v);
- }
- });
- document.write(JSON.stringify(fives) + '<br/>');
- let eat_talk = {
- name : "최나나",
- word : ['라면','빵','냉면'],
- print_wrap(){
- this.word.forEach( f =>
- document.write(this.name + '는 '+ f + '를 먹었다.<br/> ')
- );
- // this.word.forEach(function(f){
- // document.write(this.name + '는 '+ f + '를 먹었다.<br/> ')
- // }
- // );
- }
- };
- eat_talk.print_wrap();
- let lets_play_dog = {
- pet : "댕댕이",
- eat: ['사료','간식','풀을 뜯고'],
- play : ['수영' , '산책' , '쟁반던지기'],
- print_eat(){
- this.eat.forEach( e => document.write(this.pet + '가 ' + e + ' 먹고있다.<br/> ')
- );
- },
- print_play(){
- this.play.forEach( p => document.write('난 오늘 ' + this.pet + '와 ' + p + '를 했다. <br/>'))
- }
- };
- lets_play_dog.print_eat();
- lets_play_dog.print_play();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement