Lodash _.gt() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is strictly greater than other. Uses the same relational comparison as JavaScript’s > operator. Part of Lodash Lang since 3.9.0 (stable — not deprecated). Note: equal values return false — use _.gte for greater-or-equal.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.gt. Start with this line.

Lodash
_.gt(value, other)
CallWhat it does
_.gt(value, other)Primary signature.
_.gt(value)Check, compare, clone, or convert a value.

Prefer import gt from "lodash/gt" when you want a smaller bundle.

Library declarations
Lodash
_.gt(value, other)

Parameters

ParameterDescription
valueRequired. Left-hand value to compare
otherRequired. Right-hand value to compare

Return Value

Return ValueDescription
*true if value > other, else false

Lodash Examples

Example 1 — Official: Greater, Equal, Less

Strict greater-than for three classic pairs.

Lodash
console.log(_.gt(3, 1)); // true
console.log(_.gt(3, 3)); // false
console.log(_.gt(1, 3)); // false
Try It Yourself

How It Works

  1. Greater. 3 > 1 → true.
  2. Equal. 3 > 3 is false — not greater.
  3. Less. 1 > 3 → false.
  4. Same as >. Lodash wraps the language operator as a function.

Example 2 — gt vs gte

Equals pass only with greater-or-equal.

Lodash
console.log(_.gt(3, 3));  // false
console.log(_.gte(3, 3)); // true
Try It Yourself

How It Works

  1. gt. Requires a strict win → equals fail.
  2. gte. Allows equal values → true.
  3. Pick. Thresholds that include the boundary need gte.
  4. Pair. Same idea as lt vs lte on the other side.

Example 3 — String Comparison

Strings use lexicographic UTF-16 order, like >.

Lodash
console.log(_.gt("b", "a")); // true
console.log(_.gt("a", "b")); // false
console.log(_.gt("10", "9")); // false  // "1" < "9"
Try It Yourself

How It Works

  1. Letters. "b" comes after "a" → true.
  2. Reverse. "a" > "b" → false.
  3. Digits as text. "10" vs "9" is not numeric — first char "1" loses to "9".
  4. Tip. Convert with Number before comparing numeric strings.

Example 4 — NaN Comparisons Are Always False

Ordered compares involving NaN never succeed.

Lodash
console.log(_.gt(NaN, 1)); // false
console.log(_.gt(1, NaN)); // false
console.log(_.gt(NaN, NaN)); // false
Try It Yourself

How It Works

  1. Language rule. NaN > x is always false.
  2. Both sides. Either operand being NaN fails the check.
  3. Not equality. For NaN identity use _.eq.
  4. Guard. Filter with Number.isFinite before ordered compares.

Example 5 — Filter Numbers Greater Than a Threshold

Use _.gt as a named predicate with _.filter.

Lodash
var scores = [10, 25, 18, 30];

var high = _.filter(scores, function (n) {
  return _.gt(n, 20);
});

console.log(high); // [25, 30]
Try It Yourself

How It Works

  1. Threshold. Keep values where n > 20.
  2. Pass. 25 and 30 succeed.
  3. Drop. 10 and 18 fail.
  4. Why gt. Named helper reads clearly next to other Lodash lang predicates.

Browser & Runtime Support

_.gt is a Lodash 3.9+ / 4.x Lang helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines already have >; Lodash provides a function form for composition.

✓ Stable · Lodash 3.9.0+

_.gt()

Available in [email protected] full builds and the lodash/gt modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.gt Lodash 3.9.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import gt from "lodash/gt" for smaller builds. Equivalent to the native > operator as a named function.

Frequently Asked Questions

_.gt(value, other) returns true when value is strictly greater than other. It uses the same relational comparison as JavaScript’s > operator.
Yes. For the same operands you get the same truth value as the binary > operator.
gt is strict greater-than. gte is greater-than-or-equal, so _.gte(3, 3) is true while _.gt(3, 3) is false.
Any ordered comparison involving NaN is false in JavaScript. Use Number.isFinite or an explicit NaN check when you need special handling.
Like > on strings: UTF-16 code unit order, not locale-aware collation. Prefer Intl.Collator for human language sorting.
Use import gt from "lodash/gt" or require("lodash/gt") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.gt.

Next: _.gte()

Check whether one value is greater than or equal to another.

_.gte() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful