Skip to content

Instantly share code, notes, and snippets.

View jkup's full-sized avatar

Jon Kuperman jkup

View GitHub Profile
@jkup
jkup / copyWithinBasic.js
Created October 13, 2016 07:29
copyWithin
Array.prototype.copyWithin(target, start, end)
@jkup
jkup / copyWithinEx1.js
Created October 13, 2016 07:31
copyWithinEx1
[1, 2, 3, 4, 5, 6, 7, 8].copyWithin(0, 3, 5);
// copies the values from index 3 to 5 ( 4, 5 )
// plays them in place on the array starting at 0 ( value 1 )
// returns [4, 5, 3, 4, 5, 6, 7, 8]
@jkup
jkup / copyWithinEx2.js
Created October 13, 2016 07:31
copyWithinEx2
[1, 2, 3, 4, 5, 6, 7, 8].copyWithin(0, 3);
// copies the values from index 3 to the end of the array ( 4, 5, 6, 7, 8 )
// plays them in place on the array starting at 0 ( value 1 )
// returns [4, 5, 6, 7, 8, 6, 7, 8]
@jkup
jkup / function.js
Created October 13, 2016 07:34
JavaScript Function
function foo() {
console.log('bar');
}
@jkup
jkup / function.scala
Created October 13, 2016 07:35
Scala Function
def foo() {
println('bar')
}
@jkup
jkup / return.js
Created October 13, 2016 07:35
JavaScript Return
function foo() {
var bar = 42;
return bar;
}
@jkup
jkup / return.scala
Created October 13, 2016 07:36
Scala Return
def foo() {
var bar = 42
}
@jkup
jkup / semicolons.scala
Created October 13, 2016 07:37
Scala No Semicolons
object Foo {
def bar() {
println("no semicolons here!")
val xs = List(1, 2, 3, 4)
xs foreach println
def sumOfSquares(x: Int, y: Int) {
(x * x) + (y * y)
request.onload = function () {
if (this.status >= 200 && this.status < 400) {
var data = JSON.parse(this.response)
data.photos.photo.map(function (photo) {
var image = generateImageFromPhotoObject(photo)
wrapper.appendChild(image)
})
} else {
wrapper.innerHTML = 'We recieved an error from the Flickr API. Please try again later.'
function* createName() {
console.log(yield)
}
const name = createName()
name.next('Jon')