{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Jyve JS\n", "Just like it says on the tin, this runs whatever JS your browser can currently support." ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = 1" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "++x" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "JSON.stringify(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Modern browsers support:\n", "- the [`class` keyword](https://caniuse.com/#feat=es6-class) for inheritance without `prototype`\n", "- \n", "```\n", "`${string} templates`\n", "``` for concise string manipulation\n", "- [`async/await` keywords](https://caniuse.com/#feat=async-functions) for asynchronous code (inside functions)\n", "- and more!" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "class Adder {\n", " add(a, b) {\n", " document.write(\n", " `🐍 says ${a} plussss ${b} issss ${a + b}
`\n", " )\n", " return a + b;\n", " }\n", "}" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "class Adder {\n", " add(a, b) {\n", " document.write(\n", " `🐍 says ${a} plussss ${b} issss ${a + b}
`\n", " )\n", " return a + b;\n", " }\n", "}\n", "this.Adder = Adder" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "let it = new this.Adder();\n", "it.add(1, 1)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ReferenceError: sir_not_appearing_in_this_notebook is not defined" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" }, { "ename": "ReferenceError", "evalue": "sir_not_appearing_in_this_notebook is not defined", "output_type": "error", "traceback": [ "ReferenceError: sir_not_appearing_in_this_notebook is not defined", " at eval (eval at (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:157212:53), :1:1)", " at eval ()", " at Object. (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:157212:53)", " at http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:157213:36", " at new Promise ()", " at JSUnsafeKernel. (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:157205:47)", " at step (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:83284:23)", " at Object.next (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:83265:53)", " at fulfilled (http://localhost:8888/lab/static/main.74357be9c7455b0cd0fb.js:83255:58)" ] } ], "source": [ "sir_not_appearing_in_this_notebook" ] } ], "metadata": { "kernelspec": { "display_name": "JS (unsafe) — Jyve", "language": "javascript", "name": "jyve-kyrnel-js-unsafe" }, "language_info": { "codemirror_mode": { "name": "javascript" }, "file_extension": ".js", "mimetype": "text/javascript", "name": "javascript", "nbconvert_exporter": "javascript", "pygments_lexer": "javascript", "version": "ES2015" } }, "nbformat": 4, "nbformat_minor": 2 }