Skip to content

Instantly share code, notes, and snippets.

@brycebaril
Forked from junosuarez/gist:bae427e2fe5da8822864
Created May 21, 2014 16:16
Show Gist options
  • Save brycebaril/fa952d617b3efe8bf846 to your computer and use it in GitHub Desktop.
Save brycebaril/fa952d617b3efe8bf846 to your computer and use it in GitHub Desktop.
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "cat-picture",
"raw": "'cat-picture'"
}
]
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "document"
},
"property": {
"type": "Identifier",
"name": "addEventListener"
}
},
"arguments": [
{
"type": "Literal",
"value": "DOMContentLoaded",
"raw": "'DOMContentLoaded'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [],
"defaults": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "nums"
},
"init": {
"type": "ArrayExpression",
"elements": [
{
"type": "Literal",
"value": 1,
"raw": "1"
},
{
"type": "Literal",
"value": 2,
"raw": "2"
},
{
"type": "Literal",
"value": 3,
"raw": "3"
},
{
"type": "Literal",
"value": 4,
"raw": "4"
},
{
"type": "Literal",
"value": 5,
"raw": "5"
},
{
"type": "Literal",
"value": 6,
"raw": "6"
},
{
"type": "Literal",
"value": 7,
"raw": "7"
},
{
"type": "Literal",
"value": 8,
"raw": "8"
},
{
"type": "Literal",
"value": 9,
"raw": "9"
}
]
}
}
],
"kind": "var"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "text"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "nums"
},
"property": {
"type": "Identifier",
"name": "map"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "n"
}
],
"defaults": [],
"body": {
"type": "BinaryExpression",
"operator": "*",
"left": {
"type": "Literal",
"value": 2,
"raw": "2"
},
"right": {
"type": "Identifier",
"name": "n"
}
},
"rest": null,
"generator": false,
"expression": true
}
]
},
"property": {
"type": "Identifier",
"name": "join"
}
},
"arguments": [
{
"type": "Literal",
"value": "\n",
"raw": "'\\n'"
}
]
}
}
],
"kind": "var"
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "+=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "document"
},
"property": {
"type": "Identifier",
"name": "body"
}
},
"property": {
"type": "Identifier",
"name": "innerHTML"
}
},
"right": {
"type": "BinaryExpression",
"operator": "+",
"left": {
"type": "BinaryExpression",
"operator": "+",
"left": {
"type": "Literal",
"value": "<pre>",
"raw": "'<pre>'"
},
"right": {
"type": "Identifier",
"name": "text"
}
},
"right": {
"type": "Literal",
"value": "</pre>",
"raw": "'</pre>'"
}
}
}
}
]
},
"rest": null,
"generator": false,
"expression": false
}
]
}
}
]
}
require('cat-picture')
document.addEventListener('DOMContentLoaded', () => {
var nums = [1,2,3,4,5,6,7,8,9]
var text = nums.map((n) => 2*n).join('\n')
document.body.innerHTML += '<pre>' + text + '</pre>'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment