Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- // difference between let and var below
- function funky() {
- console.log(blah, otherBlah);
- let blah = 'test';
- var otherBlah = 'hello';
- }
- // funky();
- // looping over arrays below
- var arr = [12,5,7,2,8];
- for (var i = 0; i < arr.length; i++){
- // console.log('index: ' + i + ' value: ' + arr[i]);
- }
- // console.log(arr[2]);
- // item is effectively equal to doing arr[i]
- for (var item of arr) {
- // console.log(item)
- }
- // same as the old method, but without the semi-colon stuffs
- for (var i in arr) {
- var numberI = Number(i);
- console.log(i, numberI);
- console.log(arr[i])
- }
- // adding 1 below
- var g = 4;
- g++;
- g += 1;
- g = g + 1;
- // previous 3 lines do the same thing!
- var stringy = 'Hello';
- stringy = stringy + ' world!';
- // console.log(stringy.length);
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">// difference between let and var below
- function funky() {
- console.log(blah, otherBlah);
- let blah = 'test';
- var otherBlah = 'hello';
- }
- // funky();
- // looping over arrays below
- var arr = [12,5,7,2,8];
- for (var i = 0; i < arr.length; i++){
- // console.log('index: ' + i + ' value: ' + arr[i]);
- }
- // console.log(arr[2]);
- // item is effectively equal to doing arr[i]
- for (var item of arr) {
- // console.log(item)
- }
- // same as the old method, but without the semi-colon stuffs
- for (var i in arr) {
- var numberI = Number(i);
- console.log(i, numberI);
- console.log(arr[i])
- }
- // adding 1 below
- var g = 4;
- g++;
- g += 1;
- g = g + 1;
- // previous 3 lines do the same thing!
- var stringy = 'Hello';
- stringy = stringy + ' world!';
- // console.log(stringy.length);</script></body>
- </html>
Add Comment
Please, Sign In to add comment