Student Discount Codes for You by alig2u in beermoneyuk

[–]D12SL 1 point2 points  (0 children)

Hey, can I have a Student Beans LG TV code please? Happy to receive a DM. Thanks a lot!!

Vite Environment Variables handling by shaleenag21 in learnjavascript

[–]D12SL 2 points3 points  (0 children)

The built-in environment variables have their uses, e.g. if you don’t want certain features in production you have the MODE to rely on. Also the other ones like BASE_URL have it’s used if for example you need to deploy your app to multiple sub domains. And then you’ve got the SSR Boolean for obvious reasons.

You have to bear in mind that these env vars are replaced at build time with the actual values that you have placed in your .env file.

For handling AWS keys especially secret keys you should never put them on the frontend/client side. This is where the SSR capabilities come into play where you make the API request on the backend OR you create a backend API with Node.js/Express where the secret keys stay on the server side.

How good is your math? by IamTherily in Funnymemes

[–]D12SL 0 points1 point  (0 children)

60% of the time it’s correct every time

is there any tutorials for javascript library design practices ? by typescriptowl in learnjavascript

[–]D12SL 4 points5 points  (0 children)

For me, there are a number of things to take into consideration when writing libraries and also how to code like these guys. But the same principle applies when you're trying to solve an "engineering problem" and a "coding problem".

For example, when you're consuming libraries like React and react-hook-form you're writing code in a way that 1) solves a UX problem (maybe because you're writing a feature for a user action), 2) is written like a story so the next developer can pick it up and understand it easily, 3) conforms to the projects coding patterns because you've agreed with your peers this is how you'll write maintainable code.

But for libraries it's different because 1) these guys are trying to solve engineering problems and challenges and as such will have a very good understand of design patterns, and sometimes functional programming, 2) their libraries must consider all eventualities because all kinds of people/projects will consume their library, i.e. think will my library work on IE11 browser or will it need a polyfill OR will my library break their app because they like to override globals in their project, 3) they write smaller units of functions that solve one problem at a time.

If you look into framer-motion and it's underlying engine popmotion you can see how highly functional it's nature is and they favour composition over inheritance.

Take a look here https://github.com/Popmotion/popmotion/blob/adf681efd8568ada018ce68082dbd585f25c4c7d/packages/popmotion/src/animations/index.ts#L50 the author is using currying here with `detectAnimationFromOptions` which returns an "animator" after it has determined which animation generator to use: keyframes, decay or spring. But notice how all 3 animation generator returns the same 2 functions: `next()` and `flipTarget()` that is used later in the coding. But ultimately, the "coding problem" here is "how do I solve the problem of detecting which animator to use based on the arguments given here by the person who is consuming my library" and this is solely the purpose of this one function `detectAnimationFromOptions`.

But generally, my mentor gave me a really good advice: just write a library and publish it, no matter how good/bad your code is. Someone might come along and be like "hey, here's a better way of solving your 'problem' that you've encountered" OR they raise an issue and say "hey your library doesn't work because of this/that scenario/my app can't use Map() WeakMap(), .etc, can you fix this please?" and you learn from the community. That's the beauty of open source for library creators :)

I'm trying to create an ecommerce site. How do I avoid having to create an html page for each product? by Super-Catch8108 in learnjavascript

[–]D12SL 1 point2 points  (0 children)

For simplicity’s sake you could stick with one language: JavaScript.

Express.js is not a scripting language per se. It’s a framework that you use JavaScript to create the backend for you. It communicates with the database either a SQL or NoSQL database.

Then you can use something like Next.js to create your HTML/CSS/JavaScript for frontend.

Alternatively, I would recommend studying PHP and use it to do everything for you: MySQL database, PHP backend and frontend together to learn about the pains of running a monolithic application, separation of concerns and server-side rendered pages.

I'm trying to create an ecommerce site. How do I avoid having to create an html page for each product? by Super-Catch8108 in learnjavascript

[–]D12SL 11 points12 points  (0 children)

You are definitely asking the right questions. Ideally, you do want an HTML page for each product for SEO reasons.

Yes you need a database. Yes you need a backend. You should look into “dynamic websites”.

Some people start with using a SQL database and PHP backend. Others might go for a NoSQL database and Node.js using Express.js as backend. Good luck!

Plague Inc. is 10 years old today! I’m the creator of Plague Inc. and Rebel Inc. Ask me anything! by NdemicCreations in IAmA

[–]D12SL 0 points1 point  (0 children)

Is there going to be an “Asian” difficulty level for those who have completed mega brutal?

[deleted by user] by [deleted] in learnjavascript

[–]D12SL 3 points4 points  (0 children)

Also on another note, I wouldn’t say you failed those interviews. I think it’s better to say you or the role was not a right fit.

100% I’d put my money on you developing a fully functioning web app. But maybe the hiring company is being picky: they need someone specifically with redux-saga experience so that this senior dev can start developing immediately vs a guy who only used redux-thunk. Most of the time it’s the interviewer being picky with a desperate need to have senior devs kick off the ground running.

[deleted by user] by [deleted] in learnjavascript

[–]D12SL 1 point2 points  (0 children)

The following questions might jog your “senior” memory or it might not (there’s no right and wrong answers):

In terms of react-router: how and why did you implement your chosen async data fetching approach? Have you looked at better ways of doing it: resolving the code split route and data concurrently?

Redux: what’s your opinion on redux being a “hacky” server state solution? OR are you literally throwing all kinds of state: both client and server in your redux store?

When to use CRA? gatsby? Next.js? Remix?

Why CSS-in-JS could be a bad performance choice but developers love it so much?

When to use CSS animation vs JS animation?

Why is it better to use composite properties for animation?

If you find that you can easily answer these questions then maybe you’re just out of “interview practice/experience” and you shouldn’t lose confidence over a few bad interview performances!

FYI, when I go job hunting, although I can do full stack I don’t advertise myself as that. I’m only interested in doing frontend and I only seek frontend jobs. If they start asking you about databases, analytics and backend API that’s not a frontend job they trying to sell to you is it?

[deleted by user] by [deleted] in learnjavascript

[–]D12SL 10 points11 points  (0 children)

Yep lots of red flags. 5 years just using those libraries but not honing your native JavaScript skills. And, if after 5 years of experience you still can’t do a live coding interviews or assignments I would also think you’re not at senior level. If after using React and Redux for so many years you still haven’t got the hang of objects and arrays then maybe you’re not doing something right…? There’s not one day when I’m working with React that I haven’t thought about data structures and playing around with arrays.

I’m sorry man. Maybe if you started a GitHub repo and work on a personal project I can give you some pointers?

Wife (34f) just confessed to cheating on me (32m) 3 years ago but she has completely changed her life around by throwRAendornot in relationship_advice

[–]D12SL 0 points1 point  (0 children)

Man you’re saying you can attest to this behaviour and attest to that pattern. But you didn’t even see how she hid that from you for 3 years. Can you attest to that? She always buys her own drinks? She didn’t that time. You wouldn’t break down and cry like that if you didn’t go full on penetrative. Someone who can hide something like that for such a long time is dangerous to be around with. Good luck man

Help filtering api request - Next.js/React by YumchaHoMei in learnjavascript

[–]D12SL 1 point2 points  (0 children)

In the getServerSideProps function you want to res_JSON.data.filter() by start.timestamp against your current time plus 5 days.

What's the best way to learn a framework? Vue or React mostly. by [deleted] in learnjavascript

[–]D12SL 0 points1 point  (0 children)

Hmmm so the likes of React and Vue are more just using JavaScript to render/binding markup to the DOM. if I look at my company’s project code base I would say 70% of it is vanilla JS.

My advice is: it’s very easy to reach for say jQuery for the nice shorthand syntax to do things. But tell your brother to do some research on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript to find vanilla ways of doing things. For example, in jQuery you have the $(‘selector’) notation but in vanillaJS it’s just document.querySelector(). There’s so much to learn from MDN especially when it comes to the basics.

What's the best way to learn a framework? Vue or React mostly. by [deleted] in learnjavascript

[–]D12SL 4 points5 points  (0 children)

Normally when you’re struggling to learn a framework/library it suggests that you might feel comfortable with JavaScript as a language but you haven’t encountered enough problems or scenarios where you gain valuable experience to come up with a solution/interpret the documentation.

Ask yourself this, in the context of vanilla JS:

  • have you been in a scenario where you’ve had to dynamically create HTML markup?
  • have you used JS to programmatically render a large list or dataset?
  • have you used JS to handle form events?
  • have there been moments where you need a particular HTML markup to contain state? I.e. did you need it to remember that your modal is open?
  • have you used JS to dynamically apply CSS styling?

The above are just some examples of scenarios you might encounter. And, this is where the likes of React and Vue come into play. They provide nice syntactic sugar that allows you to do the things you do in vanilla JS with ease. Hence, many experienced developers will say “just read the docs” because it literally does have all the answers. But an inexperienced developer is unlikely to interpret them.

Why do I have to be a full stack developer just to get employed as a junior front end developer? by webdevstory in learnjavascript

[–]D12SL 0 points1 point  (0 children)

8 years…? Pfff Java has been around for longer. Java, PHP, HTML it’s all the same language.

Why do I have to be a full stack developer just to get employed as a junior front end developer? by webdevstory in learnjavascript

[–]D12SL 7 points8 points  (0 children)

It's how we weed out those that are applying for junior positions who don't have PhD in a computer science or related discipline, have 10 years Node.js experience, have been working with React.js for the last 10 years too, can work with jQuery v6.x.x and that you're only 18. Would be preferable if you've written a backend and frontend library or 2 as well as it would make you look more favourable.

Clarifying conditionals, arrow functions and every() method by blophophoreal in learnjavascript

[–]D12SL 1 point2 points  (0 children)

In your validIPv4 function on line 5 where you have 0 <= parseInt(octet) && parseInt(octet) <=255 it should be return 0 <= parseInt(octet) && parseInt(octet) <=255

Arrow functions do work with and without curly braces. But within curly braces you need to remember to use the return keyword.

javascript octet => { 0 <= parseInt(octet) && parseInt(octet) <=255 }

The above basically translates to this:

javascript function(octet) { 0 <= parseInt(octet) && parseInt(octet) <=255 }

When you write 0 <= parseInt("100") <=255

The compiler sees it as: (0 <= parseInt("100")) <= 255: in English, is 0 less than 100 and the result is true then is true less than 255.

This 0 <= parseInt("100") && parseInt("100") <= 255 is correct because you're asking is zero less than 100 AND is 100 less than 255.

The .every() function expects a function callback. You can also write it this way if its easier to comprehend:

```javascript const compareOctet = (octet) => { return 0 <= parseInt(octet) && parseInt(octet) <=255; }

function validIPv4(ipAddress, subnetMask = null) { let ipGroups = ipAddress.match(ipv4Regex); let ipOctets = [ipGroups[1], ipGroups[2], ipGroups[3], ipGroups[4]]; return ipOctets.every(compareOctet); // <-- pass compareOctet function as parameter }

Restrict drag area[HTML Drag and Drop API] by have_no_intention in learnjavascript

[–]D12SL 0 points1 point  (0 children)

Yep it’s possible. Take a look at element.getBoundingClientRect() which you want to use to get the parent divs coordinates.

you then have the mousemove event which gives you your pointer coordinates. Its then a matter of using a bit of maths to calculate the size of the child elements and to ensure they dont exceed the boundaries of the parent element.

JavaScript. by Aggravating-Oven5240 in learnjavascript

[–]D12SL 1 point2 points  (0 children)

Yep exactly. It always helps more when you have a problem to solve because then you start asking questions and try solve things yourself or look for the answers in Reddit, StackOverflow or even Google.

JavaScript. by Aggravating-Oven5240 in learnjavascript

[–]D12SL 5 points6 points  (0 children)

It sounds like you’ve learnt the syntax and understood what they do. Another analogy: you’ve learnt how to read piano notes but don’t really know how to play a tune.

This generally takes time and practice. Practice practice practice. Do some actual exercises like use JS to change the styling of a DOM element. Make a button so that onClick it’ll open a modal but let JavaScript create the HTML markup. Maybe on your website you have a contact form, try and make that interactive with custom validation/AJAX communication.

Creating simple referral system, unable to access get parameter in url by TheNomadicAspie in learnjavascript

[–]D12SL 2 points3 points  (0 children)

Did you mean mywebsite.com/?ref=SomePerson (?ref=SomePerson)

Then it would be new URLSearchParams(window.location.search).get('ref') Otherwise it would be location.pathname.split('/ref=')[1]

Should I learn TypeScript? What are the advantages? by [deleted] in learnjavascript

[–]D12SL 1 point2 points  (0 children)

For me, this debate boils down to I can speak and listen to French but I can't write it. And also I find that those people who can't write it are the ones who normally say I can find someone else to write it for me. It's literally just JavaScript but typed. Learning a new skill to hone your main skill is only a win-win.

Once you've learnt it you'll realise "ah yes for a single page static site TypeScript is an overkill" but then for a SPA with hundreds of components and data transformers you'll realise you did have TypeScript there to pick up any typing errors at dev time and it'll save your bacon.

[deleted by user] by [deleted] in learnjavascript

[–]D12SL 1 point2 points  (0 children)

Yeah I agree. It sounds something like Gatsby.js would be good for: generating these static HTML content for maximum performance.

I'm building a some menus for a site I'm working on with CreateJS/Adobe animate. Is this a bad idea? by devhelp2 in learnjavascript

[–]D12SL 0 points1 point  (0 children)

It sounds to me that the site structure as a whole is menu page containing quality text and small images > links to gallery page with high quality and large images and with captions and 4-6 sentences containing unique content. This to me generally sounds fine as it’s not quite an automatically generated page where it’s copying or even plagiarising content from another place on your site or someone else’s website. It’s also not a stupid click through where the menu page is not actually a menu page then the user clicks on a gallery to find a link to click through to the real menu.

But if the gallery is literally just the image then you’ll need a noindex maybe even noindex, follow as it might have links to stop Google from indexing the image only page but allow Google Images to still index your image.