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 doubles = [1, 2, 3, 4].myMap(function(number) { | |
return number * 2; | |
}); | |
// or using lambda | |
// const doubles = [1, 2, 3, 4].myMap(number => number * 2); | |
console.log(doubles); |
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
Array.prototype.myMap = function(fn) { | |
const elements = []; | |
for(let i = 0; i < this.length; i++) { | |
elements.push(fn(this[i])); | |
} | |
return elements; | |
}; |
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 doubles = [1, 2, 3, 4].map(function(number) { | |
return number * 2; | |
}); | |
// or using lambda | |
// const doubles = [1, 2, 3, 4].map(number => number * 2); | |
console.log(doubles); |
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 number2String(number) { | |
return number.toString(10); | |
} | |
function number2DoubledNumber(number) { | |
return number * 2; | |
} | |
function myMap(numbers, fn) { | |
const elements = []; |
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 number2String(number) { | |
return number.toString(10); | |
} | |
function myMap(numbers, fn) { | |
const elements = []; | |
for(let i = 0; i < numbers.length; i++) { | |
elements.push(fn(numbers[i])); | |
} |
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 myMap2(numbers) { | |
const elements = []; | |
for(let i = 0; i < numbers.length; i++) { | |
elements.push(numbers[i] * 2); | |
} | |
return elements; | |
} |
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 myMap(numbers) { | |
const elements = []; | |
for(let i = 0; i < numbers.length; i++) { | |
elements.push(numbers[i].toString(10)); | |
} | |
return elements; | |
} |
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 numbers = [1, 2, 3, 4]; | |
const elements = []; | |
for(let i = 0; i < numbers.length; i++) { | |
elements.push(numbers[i].toString(10)); | |
} | |
console.log(elements); |
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 ConsumerViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let webViewBox = createWebView(usingModern: true) | |
// add webView to the view hierachy | |
webViewBox.load(urlRequest: URLRequest(url: URL(string: "www.google.it")!)) | |
} | |
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
struct WebViewBox { | |
let view: UIView & URLRequestable | |
func load(urlRequest: URLRequest) { | |
view.load(urlRequest: urlRequest) | |
} | |
} |
NewerOlder