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
| // jest | |
| const sum = require('<module_path>/sum'); | |
| test('Add 1 and 2', () => { | |
| expect(sum(1, 2)).toBe(3); | |
| }); |
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 sum = function sumInteger(num1, num2) { | |
| const sumIntegerResult = num1 + num2; | |
| return sumIntegerResult; | |
| } |
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 arr = [1, 2, 3]; | |
| let foo; | |
| foo = arr.map(function(ele) { | |
| return ele + 1; | |
| }); | |
| foo = arr.map(ele => ele + 1); |
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 | |
| function sum_func(a, b) { | |
| return a + b; | |
| } | |
| // arrow function | |
| const sum_arrow = (a, b) => a + b; |
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 foo() { | |
| this.x = 1; | |
| this.y = 2; | |
| } | |
| foo.prototype = { | |
| bar: function() { | |
| function add() { | |
| return this.x + this.y; | |
| } |
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 foo() { | |
| this.x = 1; | |
| this.y = 2; | |
| } | |
| foo.prototype = { | |
| bar: function() { | |
| const add = () => this.x + this.y; | |
| return add(); |
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 foo() { | |
| this.x = 1; | |
| this.y = 2; | |
| } | |
| foo.prototype = { | |
| bar: function() { | |
| function add() { | |
| return this.x + this.y; | |
| } |
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
| import React, { Component, Fragment } from 'react'; | |
| class Foo extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| num: 0 | |
| } | |
| this.add = this.add.bind(this); | |
| } |
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 foo() { | |
| return 'Hello World!'; | |
| } |