Background

Javascript

entry image

Javascript

Browser Url bar run javascript

javascript:alert(1)

Decimal and hex

//hex number begin with 0x

// both have same values
0xA == 10
x = 0xA
y = 10

//can use both expression
x == 0xA
x == 10

Canvas requestAnimationFrame

var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d'); 
var ball;
var t0; // time at last call
var dt; // elapsed time between calls

window.onload = init; 

function init() {
  ball = new Ball(20,"#0000ff");
  ball.x = 50; ball.y = 250;
  ball.vx = 200;
  ball.draw(context);
  t0 = new Date().getTime(); // initialize value of t0  
  animFrame();
};

function animFrame(){
  requestAnimationFrame(animFrame,canvas);
  onEachStep();
}

function onEachStep() {
  var t1 = new Date().getTime(); // current time in milliseconds since midnight on 1 Jan 1970   

  //since the last time the call to onEachStep() was made.
  dt = 0.001*(t1-t0); 
  t0 = t1; // reset t0   (can call t0 prevTime)
  //{ t0 might be late because of these draw related things (or other computation)
     //so each step is longer  (takes a bit more time)

  ball.x += ball.vx * dt; 
  context.clearRect(0, 0, canvas.width, canvas.height);  
  ball.draw(context); 
};

Remove non-printable ascii characters from text

//printable characters of ASCII are conveniently in one continuous range
printable_ASCII_only_string = input_string.replace(/[^ -~]+/g, "");
// OR
printable_ASCII_only_string = input_string.replace(/[^\x20-\x7E]+/g, "");

https://bytefreaks.net/programming-2/javascript/javasript-remove-all-non-printable-and-all-non-ascii-characters-from-text

Get Active element

document.activeElement
'<input class=​"form-control" data-val=​"true" data-val-required=​"Category Name is Required." id=​"Name" name=​"Name" type=​"text" value>​'

document.activeElement.id
"Name"

document.activeElement.type
"text"

Dom

check tags exists or not

try {
    var doc_head = document.head.innerHTML.toString();
  } catch (e) {
    var doc_head = "Error: document has no head";
  }

Ref

"Physics for JavaScript Games, Animation, and Simulations" by Dev Ramtal and Adrian Dobre, published by Apress, 2014