r/JavaScriptTips • • Jul 16 '21

How to utilise JSDoc comment tags so that Visual Studio Code intellisense works great

Thumbnail
blog.shhdharmen.me
4 Upvotes

r/JavaScriptTips • • Jul 12 '21

Sidebar Menu HTML CSS | Without JavaScript

Thumbnail
youtu.be
4 Upvotes

r/JavaScriptTips • • Jun 15 '21

Making a 3D Model move using Tensorflow PoseNet & Three.js

Thumbnail
youtu.be
4 Upvotes

r/JavaScriptTips • • May 08 '21

OCR - Optical Character Recognition - NodeJS - made easy - Dev Life

Thumbnail
youtube.com
4 Upvotes

r/JavaScriptTips • • Apr 13 '21

Image Classification API With NodeJS, TensorflowJS, And MobileNet Model

Thumbnail self.expressjs
4 Upvotes

r/JavaScriptTips • • Apr 07 '21

Build a shareable stream in Reactive Programming in JS. (free)

4 Upvotes

Learn how to build a shareable stream in Reactive Programming.

  • Build the takeUntil operator

  • Build the endWith operator

  • Bonus: Build the repeat operator

https://app.hackjam.io/hj-details/reactive-programming-course-part-2

Register for Q&A and Demo on 12 April at 12PM CEST
https://us02web.zoom.us/meeting/register/tZErceytrDspH9H9_AuBWZPr2Ot_FrBH2Uwh


r/JavaScriptTips • • Jan 27 '21

How do I get the number to show up in the alert that I typed in the window prompt?

Post image
4 Upvotes

r/JavaScriptTips • • Dec 03 '20

Understanding Javascript Function

Thumbnail
tutorialstonight.com
4 Upvotes

r/JavaScriptTips • • May 23 '20

Create A Image Compressor Using React JS

Thumbnail
youtu.be
4 Upvotes

r/JavaScriptTips • • May 18 '20

What jQuery would look like if it was released in 2021

Thumbnail
github.com
4 Upvotes

r/JavaScriptTips • • May 14 '20

Simple algorithm for finding an element that passes a truth test

4 Upvotes

Can someone explain what this function means with regards to the test it is doing. Its supposed to automatically check the num passed into it, and if its true then it returns the num. I just don't understand how its doing it in each individual part.

function findElement(arr, func) {
let num = 0;for(var i = 0; i < arr.length; i++) {
num = arr[i];
if(func(num)) {
return num;
}
}
return undefined;
}

findElement([1, 2, 3, 4], num => num % 2 === 0);


r/JavaScriptTips • • May 13 '20

👾 Nice to know: Learn how to debug failed CircleCI jobs using SSH

Thumbnail
redd.one
4 Upvotes

r/JavaScriptTips • • Apr 25 '20

#5 Mongoose Schemas | Instance functions, Statics, Query Helpers, Virtua...

Thumbnail
youtube.com
4 Upvotes

r/JavaScriptTips • • Jun 23 '19

Daily JS interview questions

4 Upvotes

I feel like this fits here.

I just started a JS Interview Question playlist on my YouTube channel last week. Each day I post a new question and then discuss the solution.

https://www.youtube.com/watch?v=USbiLiF9NDY&list=PLyuRouwmQCjlLW9NjqoBbf9eVaFX4F9UZ

I have been teaching web development for nearly 20 years at my local college, I'm not just a hack with click bait type videos.


r/JavaScriptTips • • 3d ago

Copy Nested Form Data Before Editing

Post image
3 Upvotes

r/JavaScriptTips • • Dec 01 '25

MINECRAFT SERVER

Post image
3 Upvotes

r/JavaScriptTips • • Nov 21 '25

The Lighthouse Quick Start: Everything Beginners Need in 10 Minutes

Thumbnail medium.com
3 Upvotes

r/JavaScriptTips • • Sep 16 '25

fixing ai bugs before they appear with a tiny javascript “semantic firewall”

3 Upvotes

most “ai tips” tell you how to patch after the model speaks. this post shows a tiny semantic firewall you put before generation. beginner friendly, copy-paste js, works with local models or api calls. the goal is simple. stop wrong states from speaking.

what is a semantic firewall

think of it like a traffic cop at the junction. you inspect intent and inputs first. if the state looks unstable, you loop once, narrow scope, or ask for a missing anchor. only a stable state is allowed to produce output. once a failure class is mapped this way it tends not to come back in a different form.

before vs after in plain words

after: the model answers, then you add rerankers, regex, retries. a week later the same bug returns with new prompts. before: restate task, fix analyzers and schema, run a tiny probe. if coverage is weak or evidence is stale you stop and ask for the one missing thing. then you generate.

acceptance targets that keep you honest

  1. drift ok. the restated plan must match the user request.

  2. coverage ok. list which files or indexes or tools you will touch. majority must be covered.

  3. risk down. your quick probe should make risk go down after one loop. if risk climbs you stop.


drop-in snippet 1. rag answer with citations

beginner safe. no libraries. just structure.

// firewall_rag.ts
type Doc = { text: string; source: string; keyHits: number; ageHours: number }

type Plan = {
  intent: string
  route: "en" | "hi-en" | "auto"
  retriever: { k: number; minScore: number; tokenizer: string }
  targets: { driftOK: boolean; coverageClaim: string }
}

export function planGate(userQ: string): Plan {
  const route = /[अ-ह]/.test(userQ) ? "hi-en" : "en"
  const intent = `answer with citations. q="${userQ.trim()}"`
  const retriever = { k: 8, minScore: 0.32, tokenizer: "xlm-roberta-base" }
  const targets = { driftOK: userQ.trim().length > 0, coverageClaim: `route=${route},k=${retriever.k}` }
  return { intent, route, retriever, targets }
}

export function probeGate(ctxs: Doc[]) {
  const distinctSources = new Set(ctxs.map(c => c.source)).size
  const fresh = ctxs.filter(c => c.ageHours <= 48).length
  const evidenceHits = ctxs.filter(c => c.keyHits >= 2).length
  const coverageOK = distinctSources >= 3
  const evidenceOK = evidenceHits >= 2 && fresh >= 2
  const hazardNote = coverageOK && evidenceOK ? "stable" : "ask for index version or language lock"
  return { coverageOK, evidenceOK, hazardNote }
}

// glue it together with your own search + llm
export async function answerWithFirewall(userQ: string, searchFn: any, llmFn: any) {
  const plan = planGate(userQ)
  if (!plan.targets.driftOK) return "i need a concrete question or file scope"
  const ctxs: Doc[] = await searchFn(userQ, plan.route, plan.retriever)
  const probe = probeGate(ctxs)
  if (!(probe.coverageOK && probe.evidenceOK)) {
    return "retrieval unstable. say 'lock language=en' or give index version, then ask again"
  }
  // force citation-first style
  return llmFn({
    system: "respond in citation-first style. list sources before prose.",
    user: userQ,
    context: ctxs.slice(0, plan.retriever.k)
  })
}

what this blocks in real projects

  1. tokenizer or analyzer mismatch that ruins recall

  2. citation-less bluffing

  3. stale posts being quoted as truth


drop-in snippet 2. guaranteed json output

common frontend task. you want valid json for an invoice or form. do not let the model “speak” until the object passes minimal rules.

// firewall_json.ts
type Invoice = { id: string; customer: string; items: { name: string; qty: number; price: number }[]; total: number }

function validateInvoice(x: any): { ok: boolean; why?: string } {
  if (!x || typeof x !== "object") return { ok: false, why: "not an object" }
  if (typeof x.id !== "string" || typeof x.customer !== "string") return { ok: false, why: "missing id or customer" }
  if (!Array.isArray(x.items) || x.items.length === 0) return { ok: false, why: "items empty" }
  for (const it of x.items) {
    if (typeof it.name !== "string" || typeof it.qty !== "number" || typeof it.price !== "number") {
      return { ok: false, why: "bad item fields" }
    }
  }
  const sum = x.items.reduce((s: number, it: any) => s + it.qty * it.price, 0)
  if (Math.abs(sum - x.total) > 0.01) return { ok: false, why: "total mismatch" }
  return { ok: true }
}

export async function jsonWithFirewall(prompt: string, llmFn: any) {
  const plan = `return ONLY a JSON object for an invoice. no prose. fields: id, customer, items[{name,qty,price}], total`
  const raw = await llmFn({ system: plan, user: prompt })
  let obj: any
  try { obj = JSON.parse(raw) } catch { return "bad json. reply 'try again' to regenerate" }
  const check = validateInvoice(obj)
  if (!check.ok) return `unsafe json: ${check.why}. add missing fields and try again`
  return obj as Invoice
}

what this blocks

  1. prose wrapped around json that crashes your parser

  2. missing fields that break ui

  3. wrong totals that trigger refunds or angry emails


practical use cases for javascript devs

  1. docs chatbot with citations in your nextjs app

  2. customer support macro generator that must output valid json

  3. internal cli helper that refuses to run without fresh context

  4. cron job that drafts summaries only if today’s data is within a safe window

  5. sql or code skeleton writer that will not produce anything until it lists assumptions and files it will touch


60 second copy paste

drop this into your dev chat when giving a task to a model

act as a semantic firewall.
1) restate the task in one line.
2) list inputs, files or indexes, and api versions you will touch.
3) give 3 edge cases and 3 tiny io examples with expected outputs.
4) pick one invariant that must not break.
5) report drift_ok, coverage_ok, hazard_note. if any is false stop and ask for the missing anchor.
only then produce the final answer or code.

want the plain words version with 16 everyday failure stories and the minimal fixes Grandma Clinic → https://github.com/onestardao/WFGY/blob/main/ProblemMap/GrandmaClinic/README.md


faq

q. is this another ai library a. no. it is a small preflight pattern. works with fetch to any llm api or a local model.

q. will this slow my app a. only when the state is unstable. the time you save on rollbacks and prod hotfixes is large.

q. how do i know it worked a. log three things. the restated plan. the coverage claim. the hazard note from your probe. when a bug reappears you will see which of the three slipped.

q. i do not do rag. can this still help a. yes. the json guard snippet is the fastest win for forms, agents that call tools, and codegen that must follow a schema.

q. how do i explain this to a manager who dislikes ai a. say you added a preflight check that prevents invalid outputs. same idea as unit tests at the boundary. less debugging. fewer regressions.

q. does this work offline a. yes. the gates are plain javascript. the model can be local. the rule is simple. no stable state, no output.

—

if this keeps one wrong answer from leaking into prod, it paid for itself. bookmark the grandma link. it is mit licensed and written for beginners.


r/JavaScriptTips • • Jul 14 '25

Input needed (how to quickly learn JavaScript)

3 Upvotes

I know c# basics but I want to quickly learn JavaScript so that I can learn React next month. Any tips would be appreciated.


r/JavaScriptTips • • Mar 24 '25

Best JavaScript Courses for Interview Prep as a Software Engineering Student?

3 Upvotes

Hey everyone,

I'm a software engineering student currently looking for an internship, and I want to prepare for JavaScript-related technical interviews. I already have some experience with JavaScript, but I want to strengthen my skills, especially for coding challenges, system design, and technical questions.

Can anyone recommend the best courses or resources (Udemy, Coursera, freeCodeCamp, YouTube, etc.) to help with:
✅ JavaScript fundamentals & advanced concepts
✅ Data structures & algorithms in JavaScript
✅ System design for JavaScript-related roles
✅ React interview questions

Any advice from those who have gone through JS interviews would be greatly appreciated! 🙌

Thanks in advance! 🚀


r/JavaScriptTips • • Feb 28 '25

JAVASCRIPT

3 Upvotes

Why JavaScript is a funny language,l

🚀 true + true === 2 but true - true === 0 🤔

JavaScript has an interesting way of handling Boolean values in arithmetic:

console.log(true + true); // 2 ✅ console.log(true - true); // 0 ✅ console.log(true * 5); // 5 ✅ console.log(false + 10); // 10 ✅

🤯 Wait… since when did true become a number?

In JavaScript​: • true is implicitly converted to 1 • false is converted to 0

That’s why:

true + true → 1 + 1 → 2
true - true → 1 - 1 → 0

But watch out for this surprise:

console.log(true == 1); // true ✅ console.log(true === 1); // false ❌

😂 JavaScript​: “Equality is flexible… sometimes.”

Ever been bitten by type coercion like this? Share your funniest bug story!


r/JavaScriptTips • • Feb 18 '25

JavaScript Cheat Sheet

3 Upvotes

This cheat sheet covers the essential topics you’ll need when working with plain JavaScript. From variables and control structures to asynchronous operations and DOM manipulation, having these snippets at your fingertips can save time and reduce errors. 

https://medium.com/@mohanwebsite16/the-ultimate-plain-javascript-cheat-sheet-e27a25e00a44


r/JavaScriptTips • • Feb 16 '25

🎉 FREE Angular 19 Course – Build 30 Real-World Projects in 30 Days! 🚀

3 Upvotes

Hey everyone! 👋

I’ve just launched my brand new Udemy course, "30 Days of Angular: Build 30 Web Projects with Angular 19", and I’m offering it for FREE for a limited time! 🎁

This is a hands-on, project-based course where you’ll build 30 real-world applications, from simple projects like a counter, stopwatch, and calculator to advanced ones like a crypto chart, resume builder, and user management system. You'll even create fun games like Tic Tac Toe, Checkers, and Minesweeper! 🎮

📌 What you’ll learn:
✅ Angular fundamentals – Components, Directives, Services, HTTPClient, Pipes & more
✅ RxJS for powerful asynchronous data handling
✅ Real-world problem-solving with practical projects
✅ A final project: Your own professional portfolio website to impress employers!

🔗 Grab the free course here (Limited-time offer!)
Or, if the link doesn’t work, try this coupon: E6919C6E65BDD060261E

If you're looking to learn Angular by building real projects, this is for you. Let me know if you have any questions or feedback—I’d love to hear from you! 😊

Happy coding! 🚀🔥


r/JavaScriptTips • • Feb 12 '25

pdf library that can embed into web app w/o using canvas or iframe?

3 Upvotes

pdf library that i can embed into web app w/o using canvas or iframe? i just need to render it and add some graphics over it. thank you. open source plz.