If string contains a substring in JavaScript use the following – <script type=”text/javascript”> const string = “foo”; const substring = “oo”; console.log(string.includes(substring)); // true </script>
How do I format a date in JavaScript?
May 23, 2022
To format a date use the following code – <script type=”text/javascript”> var options = { weekday: ‘long’, year: ‘numeric’, month: ‘long’, day: ‘numeric’ }; var… Read More →
This comprehensive guide will explore the JavaScript for loop from fundamental concepts to advanced implementation patterns. As one of the most essential control flow statements… Read More →
html sortable table with Javascript
May 13, 2022
Click the button to sort the table alphabetically, by name: Sort Name Country Berglunds snabbkop Sweden North/South UK Alfreds Futterkiste Germany Koniglich Essen Germany Magazzini… Read More →
How can I prevent href redirect onclick with JavaScript
April 16, 2022
prevent href redirect onclick with JavaScript Use – d.preventDefault(); jQuery(document).on(“click”,”.seestock”,function(e) { e.preventDefault(); //jQuery(‘> span .stockstatus’, this).html(‘Save’); var qty = jQuery(this).data(‘qty’); jQuery(this).html(qty); //alert(‘hello’); });
Shuffling arrays is a fundamental operation in JavaScript programming that developers encounter across various applications, from creating card games and quiz randomizers to implementing data… Read More →
A Complete Guide to Deleting Files in Node.js: fs.unlink(), fs.rm(), and Best Practices
January 5, 2022
In the world of Node.js development, file operations are a fundamental task, and knowing how to reliably remove files is a cornerstone of building robust… Read More →
Generating PDF files with JavaScript
December 5, 2021
Generate PDF with JavaScript // Default export is a5 paper, portrait, using milimeters for units var doc = new jsPDF() doc.text(‘Hello world!’, 10, 10) doc.save(‘a5.pdf’)… Read More →
Submit AJAX Forms with JQuery // this is the id of the form $(“#idForm”).submit(function(e) { e.preventDefault(); // avoid to execute the actual submit of the… Read More →
add EventListener basic Javascript
January 20, 2020
add EventListener < span id=”elem”>Hello! < script > elem.addEventListener(‘click’,function(){ alert(‘hello’); }); </ script >