SShortSingh.
Back to feed

JavaScript Functions Explained: return, console.log, Closures and Async Basics

0
·1 views

A beginner-focused guide breaks down how JavaScript functions work, distinguishing between console.log as a side effect and return as a value-passing mechanism. The article explains that a function call always resolves to a value — either the returned result or undefined by default if no return statement executes. Using consistent examples with variables a=5 and b=10, it walks through four core variations of functions with and without console.log or return statements. It also covers parameters versus arguments, default parameter values, and why inner print statements appear before outer ones during nested calls. The guide aims to demystify common JavaScript output surprises by anchoring them to two foundational concepts: side effects and return values.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Dev Documents Kubernetes Hard Way Step 8: Controllers, API Server, and a Port Conflict

A developer building a Kubernetes homelab using the 'Kubernetes the Hard Way' guide has completed Step 8, which involves bootstrapping the Kubernetes control plane components. The step required installing and configuring the API Server, Scheduler, and Controller Manager as Linux services on the controller node. While setting up the API Server, the developer hit a failure caused by port 6443 already being in use. Investigation revealed that a forgotten k3s installation from months earlier was occupying the port. Stopping and disabling the leftover k3s service resolved the conflict and allowed the setup to proceed.

0
ProgrammingDEV Community ·

100% Model Agreement, 75% Accuracy: Why Shadow Traffic Metrics Can Mislead

A developer building SuperRouter, an open-source AI routing tool, found that a cheaper model agreed with a reference model 100% of the time during shadow traffic testing, yet was only correct 75% of the time. The finding highlights a core flaw in using inter-model agreement as a quality proxy: two models trained on overlapping data tend to fail in the same direction, making agreement highest where it is least protective. The author argues that evaluation must be scored against known ground truth — using deliberately planted faults with pre-determined correct answers — rather than against another model's output. Additional pitfalls uncovered include undetectable planted defects inflating scores, trivial test cases suppressing false-alarm rates, and published leaderboard rankings transferring poorly to product-specific tasks. The takeaway is that agreement rate is the most intuitive but most misleading metric when routing between AI models to cut costs.

0
ProgrammingDEV Community ·

Anthropic Opens Physical Biology Lab Using Claude to Aid Experimental Research

Anthropic has established a wet laboratory in the San Francisco Bay Area, marking its expansion from purely digital AI research into hands-on experimental biology. The company is deploying its Claude AI to assist scientists with literature review, hypothesis generation, and the planning and design of biology experiments. Claude plays a supportive role within human-led workflows rather than autonomously directing research or operating laboratory equipment. The lab creates a feedback loop where AI-assisted analysis can be informed by real experimental results, potentially accelerating scientific workflows. Anthropic's biology efforts also include external partnerships with organizations such as the Allen Institute and HHMI, alongside its previously announced Claude Science initiative.

0
ProgrammingDEV Community ·

How to Combine Serilog and EF Core Logs into One File in ASP.NET Core

A technical guide published on DEV Community explains how to route both standard application logs and Entity Framework Core database command logs into a single daily rolling log file using Serilog in ASP.NET Core. The setup requires several NuGet packages, including Serilog.AspNetCore and Serilog.Sinks.File, along with specific configuration entries in appsettings.json. Developers must override the default log level for the Microsoft.EntityFrameworkCore.Database.Command namespace to Information so that SQL commands are captured alongside regular messages. The configuration is wired into the application via Program.cs using the UseSerilog host extension, which reads settings from the app's configuration and enriches log context automatically. An optional project-level flag allows developers to split the output into two separate files — one for general logs and one exclusively for EF Core — if a combined file is not preferred.