Function

Function image
In programming, a function is a reusable block of code.

Think of it like a cardboard box on a production line with a simple name written on the side like “tie knot” - this function accepts a ribbon and produces the same ribbon with a particular kind of knot tied in it. Other functions might not accept any input, but produce an output of a similar format over and over again, or accept an optional input. The most important thing to remember is that functions should be re-usable and best practice follows that functions should only do one thing, making the code easier to maintain and test.

There are two types of functions - ones built into the programming language you are using like .split(" ") in TypeScript which can be applied to a string to split it by its input (in this case a space, making the function split by word), and ones you define yourself. Every function you define must have a unique name.
Try Agentic Test Management free for 21 days image
AI Agents for your entire test management cycle - to plan sprints, write tests, run them and report bugs. Try for free.
Explore MoT
Xray AI in action: Test Case & Model Generation for modern QA teams image
Wed, 17 Sep
with Ivan Fillipov, Solution Architect at Xray
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
Leading with Quality
A one-day educational experience to help business lead with expanding quality engineering and testing practices.
This Week in Testing image
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.