Remove hash from url
history.pushState(“”, document.title, window.location.pathname);
history.pushState(“”, document.title, window.location.pathname);
JavaScript, in 2022 You can use querySelectorAll, and forEach off of the resulting NodeList to do this same thing more easily in 2022. document.querySelectorAll(“#foo option”).forEach(opt => { if (opt.value == “StackOverflow”) { opt.disabled = true; } }); Do be mindful of string-comparisons, however. ‘StackOverflow’ and ‘stackoverflow’ are not the same string. As such, you can … Read more
The key needs to go on the outermost returned element. In your specific case, that means changing this: <div className=”col col-lg-4 grid-wrapper”> <BookCard key={book.id} to this: <div className=”col col-lg-4 grid-wrapper” key={book.id}> <BookCard
Strings are a value type in JS, so they can’t have any properties attached to them, no prototype, etc. Any attempt to access a property on them is technically performing the JS [[ToObject]] conversion (in essence new String). Easy way of distinguishing the difference is (in a browser) a = “foo” a.b = “bar” alert(“a.b … Read more
This question is old but as it comes up high on search results I will point out that scipy has two functions for computing the binomial coefficients: scipy.special.binom() scipy.special.comb() import scipy.special # the two give the same results scipy.special.binom(10, 5) # 252.0 scipy.special.comb(10, 5) # 252.0 scipy.special.binom(300, 150) # 9.375970277281882e+88 scipy.special.comb(300, 150) # 9.375970277281882e+88 # … Read more
I think it’s a very common issue when coming from C++. In C++ you are doing everything explicitly when it comes to copying and moving. The language was designed around copying and references. With C++11 the ability to “move” stuff was glued onto that system. Rust on the other hand took a fresh start. Rust … Read more
From Oracle Database 12c Release 2 you could use TO_NUMBER with DEFAULT … ON CONVERSION ERROR: SELECT TO_NUMBER(‘*’ DEFAULT 0 ON CONVERSION ERROR) AS “Value” FROM DUAL; Or CAST: SELECT CAST(‘*’ AS NUMBER DEFAULT 0 ON CONVERSION ERROR) AS “Value” FROM DUAL; db<>fiddle demo
You may use window.URL class: new URL(location.href).searchParams.get(‘year’) // Returns 2008 for href = “http://localhost/search.php?year=2008”. // Or in two steps: const params = new URL(location.href).searchParams; const year = params.get(‘year’);
This can be done using CSS3 columns quite easily. Here’s an example, HTML: #limheight { height: 300px; /*your fixed height*/ -webkit-column-count: 3; -moz-column-count: 3; column-count: 3; /*3 in those rules is just placeholder — can be anything*/ } #limheight li { display: inline-block; /*necessary*/ } <ul id = “limheight”> <li><a href=””>Glee is awesome 1</a></li> <li><a … Read more
First of all, take in account that returning an object will always be more readable (and very similar in performance) than having it passed by reference, so could be more interesting for your project to return the object and increase readability without having important performance differences. If you want to know how to have the … Read more