What do you want to save?
Add Code snippet
New code examples in category Javascript
-
Awgiedawgie 2022-03-27 08:50:21
3. What are private member variables. in js
function ConstructorCar(initValue) { this.publicMember = initValue; let _privateMember = initValue; //private member this.getPrivateMember = function() { return _privateMember; } this.setPrivateMember = function(v) { _privateMember = v; }}Construc... Add solution -
Lionel Aguero 2022-03-27 08:05:04
express req get json
const express = require('express'); const app = express(); app.use(express.json()); app.post('*', (req, res) => { req.body; // The json object sent to the server }); const port = 3000; app.listen(port, () => console.log(`Listening on port ${port... Add solution -
Awgiedawgie 2022-03-27 07:35:02
compress string javascript
function en(c){var x='charCodeAt',b,e={},f=c.split(""),d=[],a=f[0],g=256;for(b=1;b<f.length;b++)c=f[b],null!=e[a+c]?a+=c:(d.push(1<a.length?e[a]:a[x](0)),e[a+c]=g,g++,a=c);d.push(1<a.length?e[a]:a[x](0));for(b=0;b<d.length;b++)d[b]=S... Add solution -
Bippy 2022-03-27 07:10:04
useffect compare previous value to current
//Custom Hook function usePrevious(value) { const ref = useRef(); useEffect(() => { ref.current = value; }); return ref.current; } // Use it in useEffect const Component = (props) => { const {receiveAmount, sendAmount } = props ... Add solution -
Awgiedawgie 2022-03-27 07:05:02
queue data structure in javascript 2018
var Queue = (()=>{ const map = new WeakMap(); let _items = [] class Queue{ constructor(...items){ //initialize the items in queue map.set(this, []); _items = map.get(this); // enqueuing the items passed to the construc... Add solution -
Phoenix Logan 2022-03-26 22:10:08
express() vs express.router()
var express = require('express'); var fs = require('fs'); var app= express(); app.get('/index/profile/:id',function(req,res){ // res.send('profile with id' + req.params.id) }); app.listen(3000,'127.0.0.1'); console.log('lsitng'); Add solution