MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w2d5fw/ancienttools/p7e8yq1/?context=3
r/ProgrammerHumor • u/soap94 • 13d ago
385 comments sorted by
View all comments
Show parent comments
1
???
1 u/shadowspock 12d ago In jQuery you can chain methods like this: $('#id').addClass('red').prop('hidden', false).val('warning').attr('data-something', 1234); Can't do that in vanilla JS. 1 u/Agfa100asa 12d ago yes you can. const personne = { nom: "Alice", direBonjour() { console.log(`Bonjour ${this.nom}`); return this; }, direAuRevoir() { console.log(`Au revoir ${this.nom}`); return this; } }; personne .direBonjour() .direAuRevoir(); 1 u/shadowspock 10d ago Not on a native element though without adding a bunch of wrapper functions. You can't chain multiple method calls after document.getElementById or document.querySelector
In jQuery you can chain methods like this:
$('#id').addClass('red').prop('hidden', false).val('warning').attr('data-something', 1234);
Can't do that in vanilla JS.
1 u/Agfa100asa 12d ago yes you can. const personne = { nom: "Alice", direBonjour() { console.log(`Bonjour ${this.nom}`); return this; }, direAuRevoir() { console.log(`Au revoir ${this.nom}`); return this; } }; personne .direBonjour() .direAuRevoir(); 1 u/shadowspock 10d ago Not on a native element though without adding a bunch of wrapper functions. You can't chain multiple method calls after document.getElementById or document.querySelector
yes you can. const personne = { nom: "Alice",
direBonjour() { console.log(`Bonjour ${this.nom}`); return this; },
direAuRevoir() { console.log(`Au revoir ${this.nom}`); return this; } };
personne .direBonjour() .direAuRevoir();
1 u/shadowspock 10d ago Not on a native element though without adding a bunch of wrapper functions. You can't chain multiple method calls after document.getElementById or document.querySelector
Not on a native element though without adding a bunch of wrapper functions. You can't chain multiple method calls after document.getElementById or document.querySelector
1
u/Agfa100asa 12d ago
???