$('#header .pointerarrow').animate(
{ left: linksstart + breedte },
400, function() {
// Animation complete.
});
Category: run
how to run javascript in terminal
// With node.js installed in windows commandline
C:UsersName> node
> console.log("Hello World");
Hello World
undefined
>
$ node // now we can execute code in console
> 2 + 4 //our input
6 //output
> .exit // or ctrl + c
how to run javascript in visual studio code
// install live server and then right click on your index.html and the keep the browser ready
how to run js before submit html
<form onsubmit="return do_something()">
function do_something(){
// Do your stuff here
return true; // submit the form
return false; // don't submit the form
}
how to run js script
// With node.js installed in windows commandline
C:UsersName> node
> console.log("Hello World");
Hello World
undefined
>
$ node // now we can execute code in console
> 2 + 4 //our input
6 //output
> .exit // or ctrl + c
how to run mocha tests on asynchronous functions in script
// async/await
it('responds with matching records', async function() {
const users = await db.find({ type: 'User' });
users.should.have.length(3);
});
// promise.then()
it('should save without error', function(done) {
var user = new User('Luna');
user.save(function(err) {
if (err) done(err);
else done();
});
});
how to run multple port node
var http=require('http');
var ports = [7006, 7007, 7008, 7009];
var servers = [];
var s;
function reqHandler(req, res) {
console.log({
remoteAddress: req.socket.remoteAddress,
remotePort: req.socket.remotePort,
localAddress: req.socket.localAddress,
localPort: req.socket.localPort,
});
}
ports.forEach(function(port) {
s = http.createServer(reqHandler);
s.listen(port);
servers.push(s);
});
var http=require('http');
var url = require('url');
var ports = [7006, 7007, 7008, 7009];
var servers = [];
var s;
function reqHandler(req, res) {
var serPort=req.headers.host.split(":");
console.log("PORT:"+serPort[1]);//here i get it using http header.
}
ports.forEach(function(port) {
s = http.createServer(reqHandler);
s.listen(port);
servers.push(s);
});
var express = require('express');
let app1 = express();
let app2 = express();
app1.listen(3000, () => {
console.log("Started server on 3000");
});
app2.listen(3002, () => {
console.log("Started server on 3002");
});
how to run node js with proxy
$ npm config delete http-proxy
$ npm config delete https-proxy
$ npm config set proxy http://localhost:3128
$ npm config set https-proxy http://localhost:3128
how to run react native app
npm install -g react-native-cli
//cd to the file where your react native projects will be
react-native init albums
// Run instructions for IOS/Android
cd projects/albums
npx react-native run-ios
npx react-native run-android
react-native run-android
react-native run-ios
npm install -g react-native-cli
npx react-native init AwesomeProject
react-native start
$ npx react-native init firstapp
how to run a javascript function on page load
object.addEventListener("load", myScript);
object.onload = function(){myScript};
<element onload="myScript">
window.onload = init;
document.onload = function