Welcome to my corner of the tech universe! I'm Othmane, a passionate explorer of cloud computing and web development. This blog is my digital notebook where i share what i learned.
Nice hacks bro
My favourite tip : select elements directly by id without getElementById <h1 id='h1'></h1>
you can do to select element :
h1.style.Color instead document.getElementById('h1').style.Color
that's why it is a bad practice to use id(attribute) in HTML elements and that you should always use class(attribute), in larger scale applications you will face unpredictable behavior because Javascript will be filled with global variables
Quite Helpful,
I would like to add something to the first one.
Math.random is not actually a very good way if you want to use it for generating an id, it's okay if you are using it for some personal project.
Thing is that these functions generate a pseudo random number.
I have explained about this Here in detail.
If you want to generate more "random" random values, you can check out the Crypto global Here on MDN
👋Pierre-Henry, a passionate Sr AI Software Engineer 😎 I create cool stuff (https://github.com/Lifyzer & https://github.com/pH7Software), love problem-solving, eating veggies, & developing new skills
“It’s only work if somebody makes you do it.” • craft code • creative ideas • cutting edge • author • senior front end architect • professional scuba diver • adventures above and below the sea level
Location
Germany
Work
Senior Front End Architect, Full Stack Engineer, Creative Technologist and Scuba Diving Professional
As a passionate developer, I thrive on acquiring new knowledge. My journey began with web development, and I am now actively engaged in open source contributions, aiding individuals and businesses.
Nice tips, but i think you made a mistake on the fifth tip. It should be like this:
Thanks for sharing Kamran, here's my little one
Reverse date format and change the delimiter
Nice hacks bro
My favourite tip : select elements directly by id without getElementById
<h1 id='h1'></h1>you can do to select element :
h1.style.Color instead document.getElementById('h1').style.Color
that's why it is a bad practice to use id(attribute) in HTML elements and that you should always use class(attribute), in larger scale applications you will face unpredictable behavior because Javascript will be filled with global variables
nice bro that's great
Want to add a "Killer" trick.
A function to check if a given positive integer is a power of 2
&used here is the Bitwise AND.This is what the modulus operator
%is for. By negating the check, you return 1 (true) or 0 (false) with:console.log(!num % 2)Modulus checks if the number is divisible by a number or not, It doesn't checks for exponent.
Nice tricks. The first one is cool.
KILLER INDEED
Nice but there are some errors
like in tip 7
there should not be
.after theisArrayand there shouldn't be a,at the end it should be;fixed code
Poe's Law (look it up if you need to it's an essential part of modern internet vocabulary)
As in surely, when I read this, I read it as a parody, a joke ...
Replacing this:
with this:
is a killer one-liner indeed. Well the killer one-liner is in fact:
As in, it's one line, no-one needs (a killer).
And on a close inspection the errors aside (a hasty post it seems) they all seem to be in jest.
Side note:
matchMediais also very interesting for checking whether a certain media-query is matched or not. And also listening for changes.Cf. developer.mozilla.org/en-US/docs/W...
Quite Helpful,
I would like to add something to the first one.
Math.random is not actually a very good way if you want to use it for generating an id, it's okay if you are using it for some personal project.
Thing is that these functions generate a pseudo random number.
I have explained about this Here in detail.
If you want to generate more "random" random values, you can check out the Crypto global Here on MDN
Cheers and following you now !
Using
location.hrefis bad for the testability, better uselocation.assign(url).Cool...
Get unique items of array
Get common items between two array
Very nice tips! I really enjoy javascript one-liners and how useful and effective they are!
I believe to get the url of an email, an easier way is
const emailUrl = email => email.split("@")[1]Thanks for share at that valuable information.
Hey, while inserting the code blocks, indicate the language so that it would be nicely highlighted.
```js -> this line
Thanks for sharing this Jamran 😊
Sweet! The random string trick is super cool!
Hey Kamran,
nice tricks! If you are interested in "one line functions", check out my series "awesome JavaScript in one line of code".
Cheers!
This was very helpful, thank you soo much for these useful tips.
always welcome
(array1 || []).length
You can also try this
In the
You write (document.activeElemnt;).
The spelling is wrong i.e activeElement
Nice tips but i think that the #tip5 should've being
console.log(arr1IsEmpty); //output - true
console.log(arr2IsEmpty); // output - false