1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 18:05:07 +00:00

Base: Move "js" and "little" HackStudio projects into ~/Source/

This commit is contained in:
Andreas Kling 2020-08-05 17:25:01 +02:00
parent bc615572a9
commit db450dbc44
28 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,11 @@
var a = [1, 2, 3];
a[1] = 5;
var push_result = a.push(7);
for (var i = 0; i < a.length; ++i) {
console.log(a[i]);
}
console.log("push result: " + push_result);

View file

@ -0,0 +1,2 @@
var foo = "foobar";
console.log(foo.charAt(3));

View file

@ -0,0 +1,5 @@
console.log("I am a generic log message");
console.debug("I am a debug log message");
console.info("I am an info log message");
console.warn("I am a warning log message");
console.error("I am an error log message");

View file

@ -0,0 +1,14 @@
var now = Date.now();
console.log("Unix timestamp: " + now / 1000);
var d = new Date();
var year = d.getFullYear();
var month = (d.getMonth() + 1).toString().padStart(2, "0");
var day = d.getDate().toString().padStart(2, "0");
var hours = d.getHours().toString().padStart(2, "0");
var minutes = d.getMinutes().toString().padStart(2, "0");
var seconds = d.getSeconds().toString().padStart(2, "0");
var milliseconds = d.getMilliseconds().toString().padStart(3, "0");
console.log("Date: " + year + "-" + month + "-" + day);
console.log("Time: " + hours + ":" + minutes + ":" + seconds + "." + milliseconds);

View file

@ -0,0 +1,5 @@
var x = 0;
for (var i = 0; i !== 3; i += 1) {
x += 2;
}
x;

View file

@ -0,0 +1,5 @@
function foo() {
var x = {};
gc();
}
foo();

View file

@ -0,0 +1,4 @@
function foo(a, b) {
return a + b;
}
foo(1, 2 + 3);

View file

@ -0,0 +1,8 @@
function foo() {
var a = [];
for (var i = 0; i < 4000; ++i) {
a.push("string" + i);
}
}
foo();

View file

@ -0,0 +1,2 @@
var x = "foobar";
console.log(x.hasOwnProperty("length"));

View file

@ -0,0 +1,2 @@
javascript.hackstudio
*.js

View file

@ -0,0 +1 @@
console.log("Hello friends!")

View file

@ -0,0 +1,10 @@
const a = 1;
const computedKey = "d";
const object = {a, b: 2, "c": 3, [computedKey]: 2 + 2};
const emptyObject = {};
console.log(object.a);
console.log(object.b);
console.log(object.c);
console.log(object.d);
console.log(emptyObject.foo);

View file

@ -0,0 +1,2 @@
var foo = 1 + 2 * 3 - 4 / 5;
foo.bar();

View file

@ -0,0 +1,2 @@
function foo() { return (1 + 2) + 3; }
foo();

View file

@ -0,0 +1,7 @@
var foo = 1;
function bar() {
return 38;
}
foo = {};
foo = bar() + 4;
foo;

View file

@ -0,0 +1,11 @@
//I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
function foo() {
function bar() {
var y = 6;
}
bar();
return y;
}
console.log(foo());

View file

@ -0,0 +1,7 @@
c = 1;
function foo() {
var a = 5;
var b = 7;
return a + b + c;
}
foo();

View file

@ -0,0 +1 @@
"hello friends".length

View file

@ -0,0 +1,12 @@
var d = "Double quoted string\n";
console.log(d);
var s = 'Single quoted string\n';
console.log(s)
var e = "Escaped characters \b \f \n \r \t \v \' \" \\ \n";
console.log(e)
var u = "Unterminated string
this is not possible in js\n";
console.log(u);
var u2 = 'This is neither\n
console.log(u2);

View file

@ -0,0 +1,5 @@
try {
throw 123;
} catch (e) {
console.log(e);
}

View file

@ -0,0 +1,10 @@
try {
console.log("you should see me");
foo();
console.log("not me");
} catch (e) {
console.log("catch");
console.log(e.name);
} finally {
console.log("finally");
}

View file

@ -0,0 +1,12 @@
const object = {};
console.log(true == 1);
console.log(null == undefined);
console.log("12" == 12);
console.log(1 + "12");
console.log(12 / "12" == true);
console.log(2 * "12");
console.log(~"24");
console.log(~true);
console.log(2*2 + "4");
console.log(object == "[object Object]");

View file

@ -0,0 +1 @@
console.log(typeof undefined, typeof true, typeof 'a', typeof 1, typeof {});