Bulletproof type checks in JavaScriptUsing typeof To check what type is a variable you would most likely use the typeof function. You can even skip the parenthesis (typeof someVariable is same as typeof(someVariable)). typeof works great for: strings numbers (not if checking integer vs...3 min read·danielcobo.comMay 17, 2021
Get the first and last moment of a day in JavascriptReady-to-use functions to get the first and last millisecond of a day using a few lines of vanilla JavaScript.2 min read·danielcobo.comMay 10, 2021
Check if the user is from EU with JavaScriptObviously your best guess is to ask the user. That being said, we generally want to avoid interrupting the user. Websites and apps are (or at least should be) about what the user's needs not ours. That being said, given the many legislation requirem...3 min read·danielcobo.comMay 3, 2021
Get user's preferred languages with JavaScriptSkip to solution If you have different language settings in your website or application wouldn't it be great if you could automatically set the language the user prefers? Doing so may be easer than you think. All you have to do is use navigator.langu...1 min read·danielcobo.comApr 26, 2021
Get location by IP with JavaScriptSkip to solution. Problem Knowing your customer location can help you tailor their experience. Other times you may want to check for this information to compile statistics or comply with regulations. What's the best way to get location data? One way...4 min read·danielcobo.comApr 19, 2021